国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

一旦特定變體發(fā)生變化,Woocommerce 就會動態(tài)改變可變產(chǎn)品的價格
P粉752290033
P粉752290033 2024-01-29 00:08:22
0
1
584

我寫這個是為了提取產(chǎn)品變化價格

global $product;

        if ( $product->is_type('variable') ) {

            function get_product_variation_price($variation_id) {

                global $woocommerce; 
                $product = new WC_Product_Variation($variation_id);
                return $product->get_price_html(); 
                } 
            $product_variations = $product->get_available_variations();
            $arr_variations_id = array();
            foreach ($product_variations as $variation) {
                $product_variation_id = $variation['variation_id'];
                $product_price = get_product_variation_price($product_variation_id);
            }

            $amount = get_product_variation_price($product_variation_id);
         
        } else {
            $amount = str_replace(".", ",", $product->get_price());
        }

我想要實現(xiàn)的是,如果產(chǎn)品是可變產(chǎn)品,則金額變數(shù)會更改為當前選定的變體設(shè)定價格,但是,這始終會為我提供第一個變體價格。我怎樣才能實現(xiàn)這個目標?

P粉752290033
P粉752290033

全部回覆(1)
P粉604507867

我認為沒有任何理由創(chuàng)建一個插件來顯示變化價格,因為這是 woocommerce 的預設(shè)。可以分享為什麼要創(chuàng)建這個插件嗎?預設(shè)功能在您的網(wǎng)站上不起作用嗎?如果您只想更改價格的小數(shù)位,則可以從貨幣選項更改這些設(shè)定。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板