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


PHP WC_Product_Variation::get_price_html方法代码示例

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


在下文中一共展示了WC_Product_Variation::get_price_html方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_price_html

 /**
  * Get variation price HTML. Prices are not inherited from parents.
  *
  * @return string containing the formatted price
  */
 public function get_price_html($price = '')
 {
     $price = parent::get_price_html($price);
     if (!empty($price)) {
         $price = WC_Subscriptions_Product::get_price_string($this, array('price' => $price));
     }
     return $price;
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:13,代码来源:class-wc-product-subscription-variation.php

示例2: get_price_html

 /**
  * Get variation price HTML. Prices are not inherited from parents.
  *
  * @return string containing the formatted price
  */
 public function get_price_html($price = '')
 {
     $price = parent::get_price_html($price = '');
     return WC_Subscriptions_Product::get_price_string($this, array('price' => $price));
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:10,代码来源:class-wc-product-subscription-variation.php

示例3: array

 function bulk_order_variation_search()
 {
     // Query for suggestions
     $term = $_REQUEST['term'];
     $excluded_products = array();
     $excluded_products = apply_filters('wc_bulk_order_excluded_products', $excluded_products);
     $included_products = array();
     $included_products = apply_filters('wc_bulk_order_included_products', $included_products);
     if (empty($term)) {
         die;
     }
     $products1 = array('post_type' => array('product_variation'), 'post_status' => array('publish'), 'post_parent' => $term, 'fields' => 'ids', 'post__not_in' => $excluded_products, 'post__in' => $included_products, 'suppress_filters' => false, 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'cache_results' => false);
     $products = get_posts($products1);
     // JSON encode and echo
     // Initialise suggestions array
     global $post, $woocommerce, $product;
     $suggestions = '';
     foreach ($products as $prod) {
         $post_type = get_post_type($prod);
         if ('product_variation' == $post_type) {
             $product = new WC_Product_Variation($prod);
             $parent = wc_get_product($prod);
             $id = $product->variation_id;
             $price = number_format((double) $product->price, 2, '.', '');
             $price_html = $product->get_price_html();
             if (preg_match('/<ins>(.*?)<\\/ins>/', $price_html)) {
                 preg_match('/<ins>(.*?)<\\/ins>/', $price_html, $matches);
                 $price_html = $matches[1];
             }
             $price_html = strip_tags($price_html);
             $price = $price_html;
             $price = apply_filters('wc_bulk_order_form_price', $price, $product);
             $sku = $product->get_sku();
             $title = '';
             $attributes = $product->get_variation_attributes();
             $img = apply_filters('woocommerce_placeholder_img_src', WC_Bulk_Order_Form_Compatibility::WC()->plugin_url() . '/assets/images/placeholder.png');
             foreach ($attributes as $name => $value) {
                 $name = str_ireplace("attribute_", "", $name);
                 $terms = get_the_terms($product->id, $name);
                 foreach ($terms as $term) {
                     if (strtolower($term->name) == $value) {
                         $value = $term->name;
                     }
                 }
                 $attr_name = $name;
                 $attr_value = str_replace('-', ' ', $value);
                 if ($this->options['attribute_style'] === 'true') {
                     $title .= $attr_value . ' ';
                 } else {
                     if (strstr($attr_name, 'pa_')) {
                         $atts = get_the_terms($parent->id, $attr_name);
                         $attr_name_clean = WC_Bulk_Order_Form_Compatibility::wc_attribute_label($attr_name);
                     } else {
                         $np = explode("-", str_replace("attribute_", "", $attr_name));
                         $attr_name_clean = ucwords(implode(" ", $np));
                     }
                     $attr_name_clean = str_replace("attribute_pa_", "", $attr_name_clean);
                     $attr_name_clean = str_replace("Attribute_pa_", "", $attr_name_clean);
                     $title .= ' ' . $attr_name_clean . ": " . $attr_value;
                 }
                 $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
             }
             $parent_image = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'thumbnail');
             $parent_image = $parent_image[0];
             $img = wp_get_attachment_image_src(get_post_thumbnail_id($parent->id), 'thumbnail');
             $img = $img[0];
             if (!empty($img)) {
                 $img = $img;
             } elseif (!empty($parent_image)) {
                 $img = $parent_image;
             } else {
                 $img = apply_filters('woocommerce_placeholder_img_src', WC_Bulk_Order_Form_Compatibility::WC()->plugin_url() . '/assets/images/placeholder.png');
             }
         }
         if (!empty($id)) {
             $symbol = get_woocommerce_currency_symbol();
             $symbol = html_entity_decode($symbol, ENT_COMPAT, 'UTF-8');
             $price = html_entity_decode($price, ENT_COMPAT, 'UTF-8');
             // Initialise suggestion array
             $suggestion = array();
             $variation_switch_data = isset($this->options['variation_search_format']) ? $this->options['variation_search_format'] : '1';
             switch ($variation_switch_data) {
                 case 1:
                     if (!empty($sku)) {
                         $label = $sku . ' - ' . $title . ' - ' . $price;
                     } else {
                         $label = $title . ' - ' . $price;
                     }
                     break;
                 case 2:
                     if (!empty($sku)) {
                         $label = $title . ' - ' . $price . ' - ' . $sku;
                     } else {
                         $label = $title . ' - ' . $price;
                     }
                     break;
                 case 3:
                     $label = $title . ' - ' . $price;
                     break;
                 case 4:
//.........这里部分代码省略.........
开发者ID:hslatman,项目名称:woocommerce-bulk-order-form,代码行数:101,代码来源:variation_search_template.php

示例4: wcsCart

 function wcsCart()
 {
     global $woocommerce;
     $message = '';
     if (isset($_POST['remove_coupn']) && $_POST['remove_coupn'] != '') {
         $coupon_code = $_POST['remove_coupn'];
         // Coupon is no longer valid, based on date.  Remove it.
         if ($woocommerce->cart->has_discount(sanitize_text_field($coupon_code))) {
             if ($woocommerce->cart->remove_coupons(sanitize_text_field($coupon_code))) {
                 $woocommerce->clear_messages();
             }
             $message = $coupon_code . " code remove succesfully";
             // Manually recalculate totals.  If you do not do this, a refresh is required before user will see updated totals when discount is removed.
             $woocommerce->cart->calculate_totals();
         }
     }
     if (isset($_POST['add_coupon']) && $_POST['add_coupon'] != '') {
         $coupon_code = $_POST['add_coupon'];
         //if ( $woocommerce->cart->has_discount( $coupon_code ) ) return;
         $woocommerce->cart->add_discount($coupon_code);
         if ($woocommerce->cart->applied_coupons) {
             $message = $coupon_code . " code successfully applied";
         } else {
             $message = $coupon_code . " code does not exist";
         }
         $woocommerce->cart->calculate_totals();
     }
     if ($woocommerce->cart) {
         $items_in_cart = $woocommerce->cart->cart_contents_count;
         $prod_ids_in_cart = array();
         foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) {
             $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);
             array_push($prod_ids_in_cart, $product_id);
         }
         $test01 = 0;
         $test02 = 0;
         $test03 = 0;
         $test04 = 0;
         if (in_array("566", $prod_ids_in_cart)) {
             $test01 = 1;
         }
         if (in_array("568", $prod_ids_in_cart)) {
             $test02 = 1;
         }
         if (in_array("570", $prod_ids_in_cart)) {
             $test03 = 1;
         }
         if (in_array("572", $prod_ids_in_cart)) {
             $test04 = 1;
         }
         $how_many_tests_in_cart = $test01 + $test02 + $test03 + $test04;
         if (in_array("574", $prod_ids_in_cart)) {
             foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
                 if ($cart_item['product_id'] == 574) {
                     $woocommerce->cart->set_quantity($cart_item_key, 0);
                 }
             }
             if ($how_many_tests_in_cart == 0) {
             }
             if ($how_many_tests_in_cart == 1) {
                 $woocommerce->cart->add_to_cart('574', '1', '719', '1');
                 $_product = new WC_Product_Variation(719);
                 $price_urgent = $_product->get_price_html();
             }
             if ($how_many_tests_in_cart == 2) {
                 $woocommerce->cart->add_to_cart('574', '1', '720', '2');
                 $_product = new WC_Product_Variation(720);
                 $price_urgent = $_product->get_price_html();
             }
             if ($how_many_tests_in_cart == 3) {
                 $woocommerce->cart->add_to_cart('574', '1', '721', '3');
                 $_product = new WC_Product_Variation(721);
                 $price_urgent = $_product->get_price_html();
             }
             if ($how_many_tests_in_cart == 4) {
                 $woocommerce->cart->add_to_cart('574', '1', '722', '4');
                 $_product = new WC_Product_Variation(722);
                 $price_urgent = $_product->get_price_html();
             }
         }
         // end if there is processing in cart
         /*$product = new WC_Product( $product_id );
         		if($product_id != '574') {
         		$price = $product->price;
         		}*/
         $html = '';
         if ($woocommerce->cart->get_cart_contents_count() > 0) {
             //$html = '<ul class="cart_list product_list_widget">';
             foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) {
                 $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);
                 $product = new WC_Product($product_id);
                 if ($product_id == 574) {
                     $price = $price_urgent;
                 } else {
                     $price = $product->get_price_html();
                 }
                 $product = new WC_Product($product_id);
                 //$html .='<li class="mini_cart_item" id="product_id_'.$product_id.'"><a href="javascript:void(0);">'.$product->post->post_title.' ( '. $price.')	</a>							</li>';
                 $html .= '<tr id="product_id_' . $product_id . '"><td class="item_name">' . $product->post->post_title . '</td><td class="item_price">' . $price . '</td></tr>';
             }
//.........这里部分代码省略.........
开发者ID:WP-Panda,项目名称:allergenics,代码行数:101,代码来源:front_template.php


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