Title: Three bugs
Last modified: August 22, 2016

---

# Three bugs

 *  Resolved [David Anderson / Team Updraft](https://wordpress.org/support/users/davidanderson/)
 * (@davidanderson)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/three-bugs/)
 * 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: [http://aelia.co/shop/currency-switcher-woocommerce/](http://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://wordpress.org/plugins/affiliates-woocommerce-light/](https://wordpress.org/plugins/affiliates-woocommerce-light/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Diego](https://wordpress.org/support/users/daigo75/)
 * (@daigo75)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/three-bugs/#post-5467308)
 * [@david](https://wordpress.org/support/users/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();
       ```
   
 *  [Diego](https://wordpress.org/support/users/daigo75/)
 * (@daigo75)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/three-bugs/#post-5467309)
 * **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.
 *  [martindi1](https://wordpress.org/support/users/martindi1/)
 * (@martindi1)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/three-bugs/#post-5467694)
 * hi Diego! i need get the subtotal
 * <?php echo $order->get_subtotal();?> dont work for me
 *  [Diego](https://wordpress.org/support/users/daigo75/)
 * (@daigo75)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/three-bugs/#post-5467695)
 * [@martindi1](https://wordpress.org/support/users/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://wordpress.org/support/plugin/affiliates-woocommerce-light](https://wordpress.org/support/plugin/affiliates-woocommerce-light)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Three bugs’ is closed to new replies.

 * ![](https://ps.w.org/affiliates-woocommerce-light/assets/icon-256x256.png?rev
   =1143263)
 * [Affiliates WooCommerce Light](https://wordpress.org/plugins/affiliates-woocommerce-light/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/affiliates-woocommerce-light/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/affiliates-woocommerce-light/)
 * [Active Topics](https://wordpress.org/support/plugin/affiliates-woocommerce-light/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/affiliates-woocommerce-light/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/affiliates-woocommerce-light/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Diego](https://wordpress.org/support/users/daigo75/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/three-bugs/#post-5467695)
 * Status: resolved