久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

woocommerce 在結(jié)帳和購物車頁面中更改價(jià)格

woocommerce change price in checkout and cart page(woocommerce 在結(jié)帳和購物車頁面中更改價(jià)格)
本文介紹了woocommerce 在結(jié)帳和購物車頁面中更改價(jià)格的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號(hào)..

使用 woocommerce,在我的網(wǎng)站中,我想在購物車頁面中添加一個(gè)選擇輸入,用戶可以在其中選擇兩個(gè)選項(xiàng)之間的值,并根據(jù)該值更改價(jià)格.

With woocommerce, in my website I'd like to add in the cart page a select input where the user can select a value between two options, and depending on this value I will change the price.

到目前為止,我可以獲得總數(shù)并使用此更改它:

so far, I could get the total and change it using this :

function action_woocommerce_before_cart_totals(  ) { 
 global $woocommerce;

 $woocommerce->cart->total  = $woocommerce->cart->total*0.25;
   var_dump( $woocommerce->cart->total);}; 

問題是,當(dāng)我去結(jié)帳頁面時(shí),它沒有計(jì)算functions.php

The issue is that when I go to checkout page it doesn't take the total calculated in functions.php

謝謝你幫助我.

推薦答案

您也可以同時(shí)使用 woocommerce_review_order_before_order_total 鉤子,在結(jié)帳時(shí)顯示您的自定義價(jià)格,這樣:

You can use woocommerce_review_order_before_order_total hook too at the same time, to display your custom price in checkout, this way:

add_action( 'woocommerce_review_order_before_order_total', 'custom_cart_total' );
add_action( 'woocommerce_before_cart_totals', 'custom_cart_total' );
function custom_cart_total() {

    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
            return;

    WC()->cart->total *= 0.25;
    //var_dump( WC()->cart->total);
}

代碼位于活動(dòng)子主題(或主題)的 function.php 文件或任何插件文件中.

此代碼已經(jīng)過測(cè)試且有效.

This code is tested and works.

這篇關(guān)于woocommerce 在結(jié)帳和購物車頁面中更改價(jià)格的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗(yàn)證問題中添加自定義注冊(cè)字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡(jiǎn)單產(chǎn)品中添加一個(gè)將更改價(jià)格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 久久精品男人的天堂 | 精品免费av | 一区二区三区四区五区在线视频 | 久久久成人一区二区免费影院 | 最新国产在线 | 日韩精品一区二区三区在线观看 | 国产1区2区3区 | 国产91丝袜 | 精品三级在线观看 | 精品国产乱码久久久久久蜜退臀 | 国产精品久久久久久久久久久久冷 | 全部免费毛片在线播放网站 | 九九热在线免费视频 | 日韩第一页 | 99久久精品国产一区二区三区 | 国产 日韩 欧美 在线 | 国内精品视频在线 | 日韩精品在线观看一区二区 | 国产亚洲一区二区三区在线观看 | 天天操天天射天天舔 | 国产1区2区在线观看 | 麻豆91av | 亚洲 欧美 日韩在线 | 在线免费av观看 | 亚洲欧美视频在线观看 | sese视频在线观看 | av在线免费观看网址 | 一级黄色录像片子 | 一级片av | 欧美日韩国产中文字幕 | 国产成人免费视频网站高清观看视频 | 91精品中文字幕一区二区三区 | 日韩中文字幕av | 久久99久久99精品免视看婷婷 | 亚洲一区二区三区四区五区中文 | 99精品热视频 | 91在线影院 | 99re| www..99re | 成人性生交大片 | 亚洲天堂中文字幕 |