wpp_meta_box_save

The Woocommerce Product Payments wpp meta box save function.

Description

wpp_meta_box_save( (type) $post_id, (type) $post ); 

Parameters (2)

0. $post_id (type)
The post id.
1. $post (type)
The post.

Usage

  1. if ( !function_exists( 'wpp_meta_box_save' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-product-payments/index.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 = wpp_meta_box_save($post_id, $post); 
  12.  

Defined (1)

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

/index.php  
  1. function wpp_meta_box_save($post_id, $post) { 
  2. // Restrict to save for autosave 
  3. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 
  4. return $post_id; 
  5.  
  6. // Restrict to save for revisions 
  7. if (isset($post->post_type) && $post->post_type == 'revision') { 
  8. return $post_id; 
  9.  
  10. if (isset($_POST['post_type']) && $_POST['post_type'] == 'product' && isset($_POST['pays']) ) { 
  11.  
  12. $productIds = get_option('woocommerce_product_apply'); 
  13. if (is_array($productIds) && !in_array($post_id, $productIds) && count($productIds) <= 10) { 
  14. $productIds[] = $post_id; 
  15. update_option('woocommerce_product_apply', $productIds); 
  16.  
  17. //delete_post_meta($post_id, 'payments');  
  18. $payments = array(); 
  19. if ($_POST['pays']) { 
  20. foreach ($_POST['pays'] as $pay) { 
  21. $payments[] = $pay; 
  22. update_post_meta($post_id, 'payments', $payments); 
  23. }elseif (isset($_POST['post_type']) && $_POST['post_type'] == 'product' ) { 
  24. update_post_meta($post_id, 'payments', array());