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


PHP WC_Product::get_display_price方法代码示例

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


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

示例1: get_product_display_price

 /**
  * Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
  * Should be safe to remove when we drop WC 2.2 compatibility
  *
  * @param  WC_Product $product the product object
  * @param  string     $price   to calculate, left blank to just use get_price()
  * @param  integer    $qty     passed on to get_price_including_tax() or get_price_excluding_tax()
  * @return string
  */
 public static function get_product_display_price($product, $price = '', $qty = 1)
 {
     if (SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3()) {
         return $product->get_display_price($price, $qty);
     } else {
         if ($price === '') {
             $price = $product->get_price();
         }
         $tax_display_mode = get_option('woocommerce_tax_display_shop');
         $display_price = $tax_display_mode == 'incl' ? $product->get_price_including_tax($qty, $price) : $product->get_price_excluding_tax($qty, $price);
         return $display_price;
     }
 }
开发者ID:baden03,项目名称:access48,代码行数:22,代码来源:class-wc-price-calculator-compatibility.php

示例2: woocommerce_gravityforms_get_updated_price

function woocommerce_gravityforms_get_updated_price()
{
    global $woocommerce;
    header('Cache-Control: no-cache, must-revalidate');
    header('Content-type: application/json');
    $variation_id = isset($_POST['variation_id']) ? $_POST['variation_id'] : '';
    $product_id = isset($_POST['product_id']) ? $_POST['product_id'] : 0;
    $gform_total = isset($_POST['gform_total']) ? $_POST['gform_total'] : 0;
    $product_data = null;
    if (function_exists('get_product')) {
        $product_data = get_product($variation_id > 0 ? $variation_id : $product_id);
    } else {
        if ($variation_id > 0) {
            $product_data = new WC_Product_Variation($variation_id);
        } else {
            $product_data = new WC_Product($product_id);
        }
    }
    $discount_price = false;
    $gforms_discount_price = false;
    $base_price = $product_data->get_display_price();
    if (class_exists('WC_Dynamic_Pricing')) {
        $working_price = $base_price;
        $dynamic_pricing = WC_Dynamic_Pricing::instance();
        foreach ($dynamic_pricing->modules as $module) {
            if ($module->module_type == 'simple') {
                //Make sure we are using the price that was just discounted.
                $working_price = $discount_price ? $discount_price : $base_price;
                $working_price = $module->get_product_working_price($working_price, $product_data);
                if (floatval($working_price)) {
                    $discount_price = $module->get_discounted_price_for_shop($product_data, $working_price);
                }
            }
        }
        $gforms_base_price = $base_price + $gform_total;
        $gforms_working_price = $base_price + $gform_total;
        foreach ($dynamic_pricing->modules as $module) {
            if ($module->module_type == 'simple') {
                //Make sure we are using the price that was just discounted.
                $gforms_working_price = $gforms_discount_price ? $gforms_discount_price : $gforms_base_price;
                $gforms_working_price = $module->get_product_working_price($gforms_working_price, $product_data);
                if (floatval($gforms_working_price)) {
                    $gforms_discount_price = $module->get_discounted_price_for_shop($product_data, $gforms_working_price);
                }
            }
        }
    }
    $price = $discount_price ? $discount_price : $base_price;
    $gform_final_total = $gforms_discount_price ? $gforms_discount_price : $price + $gform_total;
    $result = array('formattedBasePrice' => apply_filters('woocommerce_gform_base_price', woocommerce_price($price), $product_data), 'formattedTotalPrice' => apply_filters('woocommerce_gform_total_price', woocommerce_price($gform_final_total), $product_data), 'formattedVariationTotal' => apply_filters('woocommerce_gform_variation_total_price', woocommerce_price($gform_total), $product_data));
    echo json_encode($result);
    die;
}
开发者ID:quinntron,项目名称:tmad,代码行数:53,代码来源:gravityforms-product-addons-ajax.php

示例3: format_wc_variation_for_square_api

 /**
  * Convert a WC Product or Variation into a Square ItemVariation
  * See: https://docs.connect.squareup.com/api/connect/v1/#datatype-itemvariation
  *
  * @param WC_Product|WC_Product_Variation $variation
  * @param bool                            $include_inventory
  * @return array Formatted as a Square ItemVariation
  */
 public static function format_wc_variation_for_square_api($variation, $include_inventory = false)
 {
     $formatted = array('name' => null, 'pricing_type' => null, 'price_money' => null, 'sku' => null, 'track_inventory' => null, 'inventory_alert_type' => null, 'inventory_alert_threshold' => null, 'user_data' => null);
     if ($variation instanceof WC_Product) {
         $formatted['name'] = __('Regular', 'woocommerce-square');
         $formatted['price_money'] = array('currency_code' => apply_filters('woocommerce_square_currency', get_woocommerce_currency()), 'amount' => $variation->get_display_price() * 100);
         $formatted['sku'] = $variation->get_sku();
         if ($include_inventory && $variation->managing_stock()) {
             $formatted['track_inventory'] = true;
         }
     }
     if ($variation instanceof WC_Product_Variation) {
         $formatted['name'] = implode(', ', $variation->get_variation_attributes());
     }
     return array_filter($formatted);
 }
开发者ID:lilweirdward,项目名称:blofishwordpress,代码行数:24,代码来源:class-wc-square-utils.php

示例4: get_composite_regular_price

 /**
  * Get min/max composite regular price.
  *
  * @param  string $min_or_max
  * @return double
  */
 public function get_composite_regular_price($min_or_max = 'min', $display = false)
 {
     if ($this->is_priced_per_product()) {
         if (!$this->is_synced()) {
             $this->sync_composite();
         }
         $price = $min_or_max === 'min' ? $this->min_composite_regular_price : $this->max_composite_regular_price;
         if ($price && $display) {
             $display_price = WC_CP()->api->get_composited_product_price($this, $this->get_base_regular_price());
             foreach ($this->price_index['regular_price'][$min_or_max] as $component_id => $product_id) {
                 $component_data = $this->get_component_data($component_id);
                 $item_qty = $component_data['optional'] === 'yes' && $min_or_max === 'min' ? 0 : $component_data['quantity_' . $min_or_max];
                 if ($item_qty) {
                     $composited_product = $this->get_composited_product($component_id, $product_id);
                     $display_price += $item_qty * $composited_product->get_regular_price($min_or_max, true);
                 }
             }
             $price = $display_price;
         }
     } else {
         $price = parent::get_regular_price();
         if ($display) {
             $price = WC_CP_Core_Compatibility::is_wc_version_gte_2_4() ? parent::get_display_price($price) : WC_CP()->api->get_composited_product_price($this, $price);
         }
     }
     return $price;
 }
开发者ID:alexbaron50,项目名称:Rockk3rs-Lab-Test,代码行数:33,代码来源:class-wc-product-composite.php

示例5: get_bundle_regular_price

 /**
  * Get min/max bundle regular price.
  *
  * @param  string $min_or_max
  * @return double
  */
 public function get_bundle_regular_price($min_or_max = 'min', $display = false)
 {
     if ($this->is_priced_per_product()) {
         if (!$this->is_synced()) {
             $this->sync_bundle();
         }
         $price = $min_or_max === 'min' ? $this->min_bundle_regular_price : $this->max_bundle_regular_price;
         if ($price && $display) {
             $display_price = WC_PB_Helpers::get_product_display_price($this, $this->get_base_regular_price());
             foreach ($this->bundled_items as $bundled_item) {
                 $bundled_item_qty = $this->bundled_quantities_index[$min_or_max][$bundled_item->item_id];
                 if ($bundled_item_qty) {
                     $display_price += $bundled_item_qty * $bundled_item->get_bundled_item_regular_price($min_or_max, true);
                 }
             }
             $price = $display_price;
         }
     } else {
         $price = parent::get_regular_price();
         if ($display) {
             $price = WC_PB_Core_Compatibility::is_wc_version_gte_2_4() ? parent::get_display_price($price) : WC_PB_Helpers::get_product_display_price($this, $price);
         }
     }
     return $price;
 }
开发者ID:alexbaron50,项目名称:Rockk3rs-Lab-Test,代码行数:31,代码来源:class-wc-product-bundle.php


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