Plugin API, Filters, Actions

This section is constantly updated as new features, functions, filters and actions are included in the plugin core. If you have a question which this page does not cover please contact us.

The information on this page is currently meant for developers and advanced users only, not regular users. You do not need to use this information to use our plugin.


This hock can be used to add additional options within main plugin settings area.

add_action('woo_mstore/options/options_output', 'my_woo_mstore_options_html');
    function my_woo_mstore_options_html()
        {
             
            ?>
            <select name="my_custom_option">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
            </select>
            <?php
                
        }

This hock can be used to save customized options inserted through woo_mstore/options/options_output within plugin main settings page.

add_filter('woo_mstore/options/options_save', 'my_woo_mstore_options_save');
function my_woo_mstore_options_save($options)
{

//add our data
$options['my_option'] = isset($_POST['my_option']) ? $_POST['my_option'] : '';

return $options;

}

Metadata keys to exclude from master product.

/**
 * @param array         $meta_keys          Metadata keys to exclude from master product
 * @param WC_Product    $master_product     Master product
 *
 * @return array
 */
function exclude_meta_from_master_product( $meta_keys, $master_product ) {
	if ( 123 == $master_product->get_id() ) {
		$meta_keys[] = '_some_product_meta_key';
	}

	return $meta_keys;
}
add_filter( 'WOO_MSTORE_admin_product/master_product_meta_to_exclude', 'exclude_meta_from_master_product', 10, 2 );

Metadata to update in master product.

/**
 * @param array         $meta_data          Metadata to update in master product
 * @param WC_Product    $master_product     Master product
 *
 * @return array
 */
function update_master_product_meta( $meta_data, $master_product ) {
	if ( 123 == $master_product->get_id() ) {
		$meta_data['_some_product_meta_key'] = '_some_product_meta_value';
	}

	return $meta_data;
}
add_filter( 'WOO_MSTORE_admin_product/master_product_meta_to_update', 'update_master_product_meta', 10, 2 );


Is slave product inherits master product updates.

/**
 * @param bool          $result         Is slave product inherits master product updates
 * @param WC_Product    $slave_product  Slave product
 *
 * @return bool
 */
function is_product_inherit_updates( $result, $slave_product ) {
	if ( 123 == $slave_product->get_id() ) {
		$result = false;
	}

	return $result;
}
add_filter( 'WOO_MSTORE_admin_product/is_product_inherit_updates', 'is_product_inherit_updates', 10, 2 );


Slave product data to update.

/**
 * @param array $products_data_diff             Slave product data to update
 * @param array $data array(
 *      WC_Product  master_product              Master product
 *      array       master_product_attributes   Master product attributes
 *      integer     master_product_blog_id      Master product blog ID
 *      array       master_product_terms        Master product terms
 *      array       master_product_upload_dir   Master product uploads directory information ( see wp_get_upload_dir() )
 *      array       options                     Plugin options
 *      WC_Product  slave_product               Slave product
 * )

 * @return array
 */
function update_slave_product_data( $products_data_diff, $data ) {
	if (
		empty( $data['options']['child_inherit_changes_fields_control__product_cat'][ get_current_blog_id() ] )
		&&
		$data['master_product']->get_ids()
	) {
		unset( $products_data_diff['category_ids'] );
	} else {
		$products_data_diff['category_ids'] = array( 1, 2, 3 );
	}

	return $products_data_diff;
}
add_filter( 'WOO_MSTORE_admin_product/master_slave_products_data_diff', 'update_slave_product_data', 10, 2 );


Metadata keys to exclude from slave product.

/**
 * @param array $meta_keys          Metadata keys to exclude from slave product
 * @param array $data array(
 *      WC_Product  master_product              Master product
 *      array       master_product_attributes   Master product attributes
 *      integer     master_product_blog_id      Master product blog ID
 *      array       master_product_terms        Master product terms
 *      array       master_product_upload_dir   Master product uploads directory information ( see wp_get_upload_dir() )
 *      array       options                     Plugin options
 *      WC_Product  slave_product               Slave product
 * )

 * @return array
 */
function exclude_slave_product_meta( $meta_keys, $data ) {
	if ( $data['slave_product']->get_meta('_some_product_meta_key') ) {
		$meta_keys[] = '_some_product_meta_key';
	}

	return $meta_keys;
}
add_filter( 'WOO_MSTORE_admin_product/slave_product_meta_to_exclude', 'exclude_slave_product_meta', 10, 2 );


Whether to update slave product.

/**
 * @param bool          $result         Whether to update slave product
 * @param WC_Product    $slave_product  Slave product
 *
 * @return bool
 */
function is_product_stock_synchronize( $result, $slave_product ) {
	if ( 123 == $slave_product->get_id() ) {
		$result = false;
	}

	return $result;
}
add_filter( 'WOO_MSTORE_admin_product/is_product_stock_synchronize', 'is_product_stock_synchronize', 10, 2 );


Metadata to update in slave product.

/**
 * @param array $meta_data          Metadata to update in slave product
 * @param array $data array(
 *      WC_Product  master_product              Master product
 *      array       master_product_attributes   Master product attributes
 *      integer     master_product_blog_id      Master product blog ID
 *      array       master_product_terms        Master product terms
 *      array       master_product_upload_dir   Master product uploads directory information ( see wp_get_upload_dir() )
 *      array       options                     Plugin options
 *      WC_Product  slave_product               Slave product
 * )
 *
 * @return array
 */
function update_slave_product_meta( $meta_data, $data ) {
	if ( $data['slave_product']->get_meta('_some_product_meta_key') != '_some_product_meta_value' ) {
		$meta_data['_some_product_meta_key'] = '_some_product_meta_value';
	}

	return $meta_data;
}
add_filter( 'WOO_MSTORE_admin_product/slave_product_meta_to_update', 'update_slave_product_meta', 10, 2 );