本文整理汇总了PHP中WC_Product_Variation::variation_is_visible方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product_Variation::variation_is_visible方法的具体用法?PHP WC_Product_Variation::variation_is_visible怎么用?PHP WC_Product_Variation::variation_is_visible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product_Variation
的用法示例。
在下文中一共展示了WC_Product_Variation::variation_is_visible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_vars
public function create_vars()
{
global $product;
if (!is_product() || !$product->is_type('variable')) {
return;
}
$att_data_hook = get_option('mp_wc_vdopp_data_hook');
// Hook data
$att_dom_sel = get_option('mp_wc_vdopp_dom_selector');
// DOM Selector
$att_data_sel = get_option('mp_wc_vdopp_data_selector');
// Data Selector
$att_before_size = apply_filters('mp_wc_vdopp_before_size', rtrim(get_option('mp_wc_vdopp_before_size'))) . ' ';
$att_before_weight = apply_filters('mp_wc_vdopp_before_weight', rtrim(get_option('mp_wc_vdopp_before_weight'))) . ' ';
$att_after_size = apply_filters('mp_wc_vdopp_after_size', ' ' . ltrim(get_option('mp_wc_vdopp_after_size')));
$att_after_weight = apply_filters('mp_wc_vdopp_after_weight', ' ' . ltrim(get_option('mp_wc_vdopp_after_weight')));
$children = $product->get_children($args = '', $output = OBJECT);
$i = 0;
foreach ($children as $value) {
$product_variatons = new WC_Product_Variation($value);
if ($product_variatons->exists() && $product_variatons->variation_is_visible()) {
$variations = $product_variatons->get_variation_attributes();
foreach ($variations as $key => $variation) {
$this->variations[$i][$key] = $variation;
}
$weight = $product_variatons->get_weight();
if ($weight) {
$weight .= get_option('woocommerce_weight_unit');
}
$this->variations[$i]['weight'] = $weight;
$this->variations[$i]['dimensions'] = str_replace(' ', '', $product_variatons->get_dimensions());
$i++;
}
}
$this->variations = wp_json_encode($this->variations);
$params = array('variations' => $this->variations, 'att_data_hook' => $att_data_hook, 'att_dom_sel' => $att_dom_sel, 'att_data_sel' => $att_data_sel, 'att_before_size' => $att_before_size, 'att_before_weight' => $att_before_weight, 'att_after_size' => $att_after_size, 'att_after_weight' => $att_after_weight, 'num_variations' => count($variations));
// enqueue the script
wp_enqueue_script('mp_wc_variation_details');
wp_localize_script('mp_wc_variation_details', 'mp_wc_variations', $params);
}