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
if ( !function_exists( 'save_variable_product_fields' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce-categories-mailchimp-groups/woocommerce-mailchimp-free.php'; } // The variation id. $variation_id = null; // NOTICE! Understand what this does before running. $result = save_variable_product_fields($variation_id);
Defined (1)
The function is defined in the following location(s).
- /woocommerce-mailchimp-free.php
- function save_variable_product_fields( $variation_id ) {
- // find the index for the given variation ID and save the associated points earned
- $index = array_search( $variation_id, $_POST['variable_post_id'] );
- if ( false !== $index ) {
- // points earned
- if ( '' !== $_POST['variable_points_earned'][ $index ] )
- update_post_meta( $variation_id, '_wc_points_earned', stripslashes( $_POST['variable_points_earned'][ $index ] ) );
- else
- delete_post_meta( $variation_id, '_wc_points_earned' );
- // maximum points discount
- if ( '' !== $_POST['variable_max_point_discount'][ $index ] )
- update_post_meta( $variation_id, '_wc_points_max_discount', stripslashes( $_POST['variable_max_point_discount'][ $index ] ) );
- else
- delete_post_meta( $variation_id, '_wc_points_max_discount' );
- }
- }