process_shop_order

The WooCommerce Sisow Mastercard process shop order function.

Description

process_shop_order( $post_id, $post ); 

Parameters (2)

0. $post_id
The post id.
1. $post
The post.

Usage

  1. if ( !function_exists( 'process_shop_order' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-sisow-mastercard/sisow/base.php'; 
  3.  
  4. // The post id. 
  5. $post_id = null; 
  6.  
  7. // The post. 
  8. $post = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = process_shop_order($post_id, $post); 
  12.  

Defined (1)

The function is defined in the following location(s).

/sisow/base.php  
  1. function process_shop_order($post_id, $post) { 
  2. $old_fee = get_post_meta($post_id, '_processing_fee', true); 
  3. $new_fee = stripslashes($_POST['_processing_fee']); 
  4. $order_total = get_post_meta($post_id, '_order_total', true); 
  5.  
  6. if ($old_fee != '') { 
  7. if ($new_fee == 0 || $new_fee == '') { 
  8. // if there is a processing fee which is now being removed 
  9. $order_total -= $old_fee; 
  10. } else { 
  11. // adding or subtracting of fee 
  12. if ($old_fee > $new_fee) { 
  13. // fee lessened 
  14. $diff = $old_fee - $new_fee; 
  15. $order_total -= $diff; 
  16. } elseif ($old_fee < $new_fee) { 
  17. // fee added 
  18. $diff = $new_fee - $old_fee; 
  19. $order_total += $diff; 
  20.  
  21. update_post_meta($post_id, '_order_total', $order_total); 
  22. update_post_meta($post_id, '_processing_fee', $new_fee);