Jeremiah Castillo

Forum Replies Created

Viewing 21 posts - 1 through 21 (of 21 total)
Dec 4, 2024 at 5:42 pm
#201862
Participant
Jeremiah Castillo
OP

Yah and still an issue

Dec 4, 2024 at 2:53 am
#201829
Participant
Jeremiah Castillo
OP

seeing this error [02-Dec-2024 04:55:10 America/Chicago] PHP Warning: Undefined array key “HTTP_REFERER” in /home2/dataeel/public_html/wp-content/plugins/download-manager/src/User/Login.php on line 199

Dec 4, 2024 at 2:42 am
#201828
Participant
Jeremiah Castillo
OP
This reply has been marked as private.
Dec 3, 2024 at 6:15 pm
#201811
Participant
Jeremiah Castillo
OP
This reply has been marked as private.
Aug 27, 2024 at 3:30 am
#198331
Participant
Jeremiah Castillo
OP

For prepaid credits need the following to allow admin settings for return.

function ShowPaymentForm($AutoSubmit = 0)
{
global $current_user, $wpdb;

$orderid = Session::get(‘orderid’);
if (self::checkCredits())
\WPDMPP\Libs\Order::complete_order($orderid);
else return “<div class=’alert alert-danger’>”.__(‘Not enough balance’,’wpdmpc’).”</div>”;

$wpdb->insert(
“{$wpdb->prefix}ahm_credit_history”,
array(
‘credit’ ► $this->Amount,
‘price’ ► 0,
‘time’ ► time(),
‘status’ ► “spent”,
‘uid’ ► get_current_user_id(),
‘comment’ ► get_current_user_id(),

),

array(
‘%f’,
‘%f’,
‘%d’,
‘%s’,
‘%d’,
‘%s’
)
);

$balance = get_user_meta($current_user->ID, “prepaid_credits”, true);
update_user_meta($current_user->ID, “prepaid_credits”, ($balance – $this->Amount));

$Form = “<div class=’alert alert-success’><b>Payment Completed Successfully</b><br/><i class=’fa fa-sun fa-spin’></i> Redirecting…</div><script>location.href=’/member-dashboard’;</script>”;

//$Form .= get_user_meta( $current_user->ID, “prepaid_credits”, true );

return $Form;

}

it is in the wpdm-prepaid_credit file

Aug 27, 2024 at 2:49 am
#198330
Participant
Jeremiah Castillo
OP

Ok so subscription gives a zero payment requirement and the redirect is in wpdm-premium-packages.php and the function is

`
/**
* Placing order from checkout process
*/
function place_order( $order_id ) {
//if(floatval(wpdmpp_get_cart_total()) <= 0 ) return;
global $wpdb;
$order = new Order();
$order = $order->getOrder( $order_id );
$order_total = $order->total;
$tax = $order->tax;

$items = maybe_unserialize( $order->cart_data );
//$cart_data = wpdmpp_get_cart_data();

if ( ! is_array( $items ) || count( $items ) == 0 ) {
Messages::Error( __( “Cart is Empty!”, “wpdm-premium-packages” ), 0 );
die();
}

$order_title = $order->title;

do_action( “wpdm_before_placing_order”, $order_id );

// If order total is not 0 then go to payment gateway
if ( $order_total > 0 ) {

$payment = new Payment();
$payment->initiateProcessor( wpdm_query_var( ‘payment_method’, ‘txt’ ) );
$payment->Processor->OrderTitle = $order_title;
$payment->Processor->InvoiceNo = $order_id;
$payment->Processor->Custom = $order_id;
$payment->Processor->Amount = number_format( $order_total, 2, “.”, “” );

echo $payment->Processor->showPaymentForm( 1 );

if ( ! isset( $payment->Processor->EmptyCartOnPlaceOrder ) || $payment->Processor->EmptyCartOnPlaceOrder == true ) {
wpdmpp_empty_cart();
}

die();

} else {
// if order total is 0 then empty cart and redirect to home
Order::complete_order( $order_id );
wpdmpp_empty_cart();
//wpdmpp_js_redirect( wpdmpp_orders_page( ‘id=’ . $order_id ) );
wpdmpp_js_redirect(‘/member-dashboard’ );
}
}’

I added my own redirect but be great if this was a dynamic item in settings.

Aug 27, 2024 at 2:42 am
#198329
Participant
Jeremiah Castillo
OP

Thanks I just recoded orders.php and have manual updates. Hopefully in future upgrades we have more flexibility on table titles, currency, and listing the items. Especially for prepaid credits

Aug 26, 2024 at 3:28 am
#198297
Participant
Jeremiah Castillo
OP

Only issue when setting up credits as a currency the stripe payment module uses that currency and hits an error. Way to separate the two.

Aug 26, 2024 at 3:27 am
#198296
Participant
Jeremiah Castillo
OP

Yah but still want the listed items. I just recoded orders.php for now

Aug 21, 2024 at 6:04 pm
#198206
Participant
Jeremiah Castillo
OP

Thanks have updated and will check.

Also have shortcode that adds currency:

function add_custom_currency($currencies) {
// Add custom currency ‘Credits’
$currencies[‘CRD’] = ‘Credits’;
return $currencies;
}
add_filter(‘wpdmpp_currencies’, ‘add_custom_currency’);

function add_custom_currency_data($currencies) {
$currencies[‘CRD’] = array(
‘numeric_code’ ► 999, // Custom numeric code
‘code’ ► ‘CRD’,
‘name’ ► ‘Credits’,
‘symbol’ ► ‘ C’,
‘fraction_name’ ► ‘Credit’,
‘decimals’ ► 0, // Adjust according to your needs
);
return $currencies;
}
add_filter(‘wpdmpp_currencies’, ‘add_custom_currency_data’);

Aug 12, 2024 at 4:37 pm
#197887
Participant
Jeremiah Castillo
OP

Not an issue just doesn’t have the option to change redirect url for completed payment. My client doesn’t want to go to the invoice when transaction is complete. He wants to go to a custom dashboard we created.

Aug 11, 2024 at 3:17 am
#197838
Participant
Jeremiah Castillo
OP

Using Pay with credits

Aug 10, 2024 at 4:20 pm
#197834
Participant
Jeremiah Castillo
OP

That is for the test pay. I am using site credits addon

Aug 9, 2024 at 1:04 pm
#197810
Participant
Jeremiah Castillo
OP

Keep me updated

Aug 1, 2024 at 11:12 pm
#197594
Participant
Jeremiah Castillo
OP

On the emails template you use the shortcode {{items}} that shows a list of the items purchased. The issue is the list shows $ currency for the item price when we have credits as the primary currency. Need to remove the $ symbol for credit purchases.

Aug 1, 2024 at 11:07 pm
#197593
Participant
Jeremiah Castillo
OP
function check_item_purchased($pid) {
    if (!is_user_logged_in()) {
        return false;
    }
    
    global $wpdb;
    $current_user = wp_get_current_user();
    $uid = $current_user->ID;

    $orderid = $wpdb->get_var(
        $wpdb->prepare(
            "SELECT o.order_id 
             FROM {$wpdb->prefix}ahm_orders o 
             JOIN {$wpdb->prefix}ahm_order_items oi 
             ON o.order_id = oi.oid 
             WHERE o.uid = %d 
             AND oi.pid = %d 
             AND o.order_status = 'Completed'", 
             $uid, 
             $pid
        )
    );

    return $orderid ? true : false;
}

function check_item_purchased_api() {
    $pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0;
    $purchased = check_item_purchased($pid);

    wp_send_json([
        'purchased' ► $purchased
    ]);
}

add_action('wp_ajax_check_item_purchased', 'check_item_purchased_api');
add_action('wp_ajax_nopriv_check_item_purchased', 'check_item_purchased_api');
Aug 1, 2024 at 11:05 pm
#197592
Participant
Jeremiah Castillo
OP

I created some code to do it:

document.addEventListener('DOMContentLoaded', function () {
	
    // Select all buttons that have a class starting with 'btn-addtocart-'
    const buttons = document.querySelectorAll('.btn-addtocart');

    buttons.forEach(button ► {
        // Extract the item ID from the button's class list
        const itemId = Array.from(button.classList).find(cls ► cls.startsWith('btn-addtocart-')).replace('btn-addtocart-', '');
        
        // Make an AJAX request to check if the item has been purchased
        fetch(<code>/wp-admin/admin-ajax.php?action=check_item_purchased&pid=${itemId}</code>)
            .then(response ► response.json())
            .then(data ► {
                if (data.purchased) {
                    // Disable the button and change the text if the item is already purchased
                    button.disabled = true;
                    button.textContent = 'Already Purchased! ';
		    button.style.backgroundColor = 'red';
                    button.style.borderColor = 'red'; // Optional: If you want to change the border color as well
                }
            });
    });
});
Jul 26, 2024 at 7:38 pm
#197403
Participant
Jeremiah Castillo
OP

Yah it confuses my customers as 1 credit is $5.00 but when they get the invoice it shows $1.00.

Dec 24, 2023 at 2:33 pm
#192152
Participant
Jeremiah Castillo
OP

disregard figured it out. Thanks

Dec 24, 2023 at 2:26 pm
#192151
Participant
Jeremiah Castillo
OP

Looking to remove currency from cart page. Our packages are priced as credits and in order to have both credits and subscription to work we need to remove the $ currency from the page to not confuse people.

Dec 4, 2023 at 4:36 pm
#191788
Participant
Jeremiah Castillo
OP

Disregard figured it out

Viewing 21 posts - 1 through 21 (of 21 total)