当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Product_Variation::exists方法代码示例

本文整理汇总了PHP中WC_Product_Variation::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product_Variation::exists方法的具体用法?PHP WC_Product_Variation::exists怎么用?PHP WC_Product_Variation::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Product_Variation的用法示例。


在下文中一共展示了WC_Product_Variation::exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
 }
开发者ID:sonnetmedia,项目名称:otherpress.com,代码行数:40,代码来源:wc-attributes-on-page.php

示例2: foreach

	<thead>
		<tr>
			<th class="product-name">&nbsp;</th>
			<th class="product-price">&nbsp;</th>
			<th class="product-add-to-cart">&nbsp;</th>
            <th class="product-remove">&nbsp;</th>
		</tr>
	</thead>
	<tbody>
    <?php 
$i = 1;
foreach ($aUsersWishlist as $iProductId => $aWshlistItemData) {
    if ($aWshlistItemData['type'] == 'variable' && !empty($aWshlistItemData['vid'])) {
        foreach ($aWshlistItemData['vid'] as $iVariableProductId) {
            $oProduct = new WC_Product_Variation($iVariableProductId, $iProductId);
            if ($oProduct->exists()) {
                include UniWishlist()->plugin_path() . '/includes/views/item-variation-table-row.php';
            }
        }
    } else {
        $oProduct = new WC_Product($iProductId);
        if ($oProduct->exists()) {
            include UniWishlist()->plugin_path() . '/includes/views/item-table-row.php';
        }
    }
    $i++;
}
?>
    </tbody>
</table>
开发者ID:primus1989,项目名称:https---github.com-DataDesignSystems-drishtiq,代码行数:30,代码来源:wishlist.php


注:本文中的WC_Product_Variation::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。