save_variable_product_fields

The Woocommerce categories Mailchimp groups save variable product fields function.

Description

save_variable_product_fields( $variation_id ); 

Parameters (1)

0. $variation_id
The variation id.

Usage

  1. if ( !function_exists( 'save_variable_product_fields' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-categories-mailchimp-groups/woocommerce-mailchimp-free.php'; 
  3.  
  4. // The variation id. 
  5. $variation_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = save_variable_product_fields($variation_id); 
  9.  

Defined (1)

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

/woocommerce-mailchimp-free.php  
  1. function save_variable_product_fields( $variation_id ) { 
  2. // find the index for the given variation ID and save the associated points earned 
  3. $index = array_search( $variation_id, $_POST['variable_post_id'] ); 
  4. if ( false !== $index ) { 
  5. // points earned 
  6. if ( '' !== $_POST['variable_points_earned'][ $index ] ) 
  7. update_post_meta( $variation_id, '_wc_points_earned', stripslashes( $_POST['variable_points_earned'][ $index ] ) ); 
  8. else 
  9. delete_post_meta( $variation_id, '_wc_points_earned' ); 
  10. // maximum points discount 
  11. if ( '' !== $_POST['variable_max_point_discount'][ $index ] ) 
  12. update_post_meta( $variation_id, '_wc_points_max_discount', stripslashes( $_POST['variable_max_point_discount'][ $index ] ) ); 
  13. else 
  14. delete_post_meta( $variation_id, '_wc_points_max_discount' );