Title: MultiSafepayDev's Replies | WordPress.org

---

# MultiSafepayDev

  [  ](https://wordpress.org/support/users/multisafepaydev/)

 *   [Profile](https://wordpress.org/support/users/multisafepaydev/)
 *   [Topics Started](https://wordpress.org/support/users/multisafepaydev/topics/)
 *   [Replies Created](https://wordpress.org/support/users/multisafepaydev/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/multisafepaydev/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/multisafepaydev/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/multisafepaydev/engagements/)
 *   [Favorites](https://wordpress.org/support/users/multisafepaydev/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] No email low stock](https://wordpress.org/support/topic/no-email-low-stock/)
 *  [MultiSafepayDev](https://wordpress.org/support/users/multisafepaydev/)
 * (@multisafepaydev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/no-email-low-stock/page/4/#post-6433154)
 * [@mike](https://wordpress.org/support/users/mike/) Jolley,
 * Let me explain how we have set it up.
 * 1. The “multisafepay” plugin is used for configuration purposes so that all payment
   methods we offer can be configured on one location. We have created separate 
   payment plugins that use the main module as a configuration module because. The
   payment plugin depend on the main module, if that one is not installed, the others
   can’t install (at least in our internal release). So the notification url used
   is always of the main module, as the functions that are process in the response
   function is the same for all methods. This way we don’t have to create separate
   full blown plugins for every payment method.
 * 2.The trigger for the new order email is configurable. This has been added by
   request of some of our merchants. They seem to have problems with those e-mails
   on some specific wordpress/woocommerce versions. That is why its added but is
   configurable.
 * 3.This has already beens solved internally for the next release, but this has
   nothing to do with the problem described within this topic.
 * 4. This has also been fixed in the internal release for the next update, think
   this one should also not cause the issue described within this topic.
 * 5. This has been done because there were some issues with a specific woocommerce
   update. We noticed that for some reason the updates didn’t work anymore and did
   work again using the prefix. Although after another woocommerce update it was
   working again. As the order is fully updated and the stock is processed, this
   should also should not cause the issue described withint this ticket.
 * 6. The notices are also fixed internally and will be in the next update, this
   should also not cause the issue described within this topic.
 * This was a short explanation on why we did some things.
 * It’s important that we can fix the problem for Mvdw as we won’t be getting far
   by blaming each other of this problem, so lets start looking at where we are 
   now in my opinion:
 * 1. The Multisafepay plugin uses $order->payment_complete() to update the order
   as described within the Woocommerce API documentation. Notice the text “This 
   will ensure stock reductions are made, and the status is changed to the correct
   value.” on the page:[http://docs.woothemes.com/document/payment-gateway-api/](http://docs.woothemes.com/document/payment-gateway-api/)
 * 2. Using the $order->payment_complete() function, the order is successfully updated
   and set as paid. Also, according to the order notes, the stock has now been processed.
   The order comments show that the stock has been reduced for the ordered products.
 * 3. As $order->payment_complete() updates the order and triggers the stock updates
   within Woocommerce, this function call should also trigger sending the low_stock
   and no_stock e-mails, and this doesn’t seem to work i.c.m. with our plugin.
 * So we should look at the following questions:
 * 1. Does Woocommerce require some specific data being set within the order object
   before calling $order->payment_complete() that is needed to send the e-mails?
 * 2. If the answer to question 1 is yes, then what is that data and should our 
   payment module set that data, or should it be done somewhere else?
 * 3, if the answer to question 1 is no, then the next question would be why somewhere
   further within Woocommerce something goes wrong with triggering the e-mails.
 * As mentioned some post earlier, I did some debugging to figure out what is going
   wrong. I could trace the action to send the e-mails to be still working till 
   the following Woocommerce code (so not part of our plugin):
 *     ```
       if ( ! $notification_sent && 'yes' == get_option( 'woocommerce_notify_low_stock' ) && get_option( 'woocommerce_notify_low_stock_amount' ) >= $new_stock ) {
       															do_action( 'woocommerce_low_stock', $product );
       														}
       ```
   
 * Till the code above it all seems to work.
 * Now, lets start looking deeper into the process of sending these e-mails instead
   of looking at what might be wrong within the plugin, even if it should not cause
   the problem described by the topic starter as the updating of the order does 
   work as does the stock reduction as can be seen within the order notes.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] No email low stock](https://wordpress.org/support/topic/no-email-low-stock/)
 *  [MultiSafepayDev](https://wordpress.org/support/users/multisafepaydev/)
 * (@multisafepaydev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/no-email-low-stock/page/3/#post-6433116)
 * [@mike](https://wordpress.org/support/users/mike/) Jolley,
 * That is correct, as the plugin uses a return url for plugins/multisafepay/multisafepay.
   php, so that plugin is called when returning back to WooCommerce (als used for
   notification on the background).
 * So plugins/multisafepay/multisafepay.php is resposible for the updates, and this
   also works perfectly as the order is updated, and the stock is also processed,
   only the action that triggers the sending of the e-mails some how don’t really
   trigger the e-mail sending process.
 * So for the logic you should be in plugins/multisafepay/multisafepay.php.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] No email low stock](https://wordpress.org/support/topic/no-email-low-stock/)
 *  [MultiSafepayDev](https://wordpress.org/support/users/multisafepaydev/)
 * (@multisafepaydev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/no-email-low-stock/page/2/#post-6433114)
 * Hello Mike Jolley,
 * Aha that explains it. All multisafepay_xxxx.php plugins extend multisafepay.php.
   Within it we use the function Multisafepay_Response() we have a switch that checks
   transaction status and updates the order accordingly.
 * In our 2.2.0 plugin files you have the $order->payment_complete() call on lines
   1227 and 1342.
 * You can even see the commented other calls for stock reduction and update_status,
   but according to the API documentation we have changed it to payment_complete();
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] No email low stock](https://wordpress.org/support/topic/no-email-low-stock/)
 *  [MultiSafepayDev](https://wordpress.org/support/users/multisafepaydev/)
 * (@multisafepaydev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/no-email-low-stock/page/2/#post-6433112)
 * Hello [@mike](https://wordpress.org/support/users/mike/) Jolley,
 * We (MultiSafepay) have looked into this and at your reply about not doing the
   status update and stock reduction. According to the API documentation we use 
   $order->payment_complete(), (Once we confirmed the payment was succesfull) this
   function is updating the order to processing and does also process the reduction
   of the product stock.
 * Within the order you can also see the order notes about it, as example:
    Item#
   8 stock reduced from 3 to 2. added on August 21, 2015 at 10:55 am by admin Delete
   note
 * Order item stock reduced successfully.
    added on August 21, 2015 at 10:55 am 
   by admin Delete note
 * When trying to figure out what is going wrong I can go debug up to:
 *     ```
       if ( ! $notification_sent && 'yes' == get_option( 'woocommerce_notify_low_stock' ) && get_option( 'woocommerce_notify_low_stock_amount' ) >= $new_stock ) {
       															do_action( 'woocommerce_low_stock', $product );
       														}
       ```
   
 * So the plugin does call the stock updates through $order->payment_complete() 
   and even triggers the action within the if statement, but even then the low order
   e-mail is not being send.
 * When testing with the default cheque plugin it does seem to work so I guess there
   must be an issue with the available data/processing flow that is causing this
   issue.
 * Do you have an idea what could cause this issue?

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