• Hi,

    This plugin looks useful; however, I have three problems with the WooCommerce integration:

    1) Referral commissions are awarded as soon as an order is placed – not when payment is completed.

    So, if someone places an order but does not complete payment (e.g. they press “Place Order” and then go to the PayPal Express screen, but do not complete payment).

    2) Similarly, referrals are not deleted if an order is refunded – or even entirely deleted.

    3) The currency is always shown as the shop’s base currency, even if the purchase was in a different currency.
    I am using the market-leading “WooCommerce currency switcher” plugin to offer my customers payments in other currencies: https://aelia.co/shop/currency-switcher-woocommerce/
    This plugin stores the information as order meta-data, so your plugin could extract it, and store the information in the correct currency. I realise this is probably more of an enhancement than a bug!

    Best wishes,
    David

    https://www.ads-software.com/plugins/affiliates-woocommerce-light/

Viewing 4 replies - 1 through 4 (of 4 total)
  • @david
    The order currency is stored natively by WooCommerce, even when our product is not used. It’s true that, in basic WooCommerce, the order currency, when the order is placed, always matches the base currency, but that’s more of a coincidence than an ideal logic. This integration plugin should always take the order currency, and it can be done easily by using standard WooCommerce calls (see below).

    Fix for the currency issue
    Modify method Affiliates_WooCommerce_Light_Integration::woocommerce_checkout_order_processed() to take the order currency, as follows.

    Original code

    public static function woocommerce_checkout_order_processed( $order_id ) {
    	$order_total        = get_post_meta( $order_id, '_order_total', true );
    	$order_tax          = get_post_meta( $order_id, '_order_tax', true );
    	$order_shipping     = get_post_meta( $order_id, '_order_shipping', true );
    	$order_shipping_tax = get_post_meta( $order_id, '_order_shipping_tax', true );
    
    	$order_subtotal = $order_total - $order_tax - $order_shipping - $order_shipping_tax;
    
    	$currency       = get_option( 'woocommerce_currency' );

    Fixed code

    public static function woocommerce_checkout_order_processed( $order_id ) {
    	$order = new WC_Order( $order_id );
    
    	$order_total        = get_post_meta( $order_id, '_order_total', true );
    	$order_tax          = get_post_meta( $order_id, '_order_tax', true );
    	$order_shipping     = get_post_meta( $order_id, '_order_shipping', true );
    	$order_shipping_tax = get_post_meta( $order_id, '_order_shipping_tax', true );
    
    	$order_subtotal = $order_total - $order_tax - $order_shipping - $order_shipping_tax;
    
    	// Get the currency from the order, rather than the base one
    	$currency       = $order->get_order_currency();

    One more suggestion
    I would recommend not to use get_post_meta() to retrieve orders’ attributes. Class WC_Order includes many convenience methods that allow to access the data, and they evolve with WooCommerce. Should the WooCommerce Core developers decide to change the keys of the order meta, the get_post_meta() calls would fail, while the WC_Order methods would keep working, as they would reflect the changes.

    hi Diego! i need get the subtotal

    <?php echo $order->get_subtotal();?> dont work for me

    @martindi1 I’m not the author of this plugin, I don’t provide support for it. I was just sending a suggestion to the author.

    I would recommend opening a new support request: https://www.ads-software.com/support/plugin/affiliates-woocommerce-light

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Three bugs’ is closed to new replies.