$replace_order = new WC_Cart();
$replace_order->empty_cart( true );
$replace_order->add_to_cart( "256", "1");
Run Code Online (Sandbox Code Playgroud)
以上代码将产品添加256到购物车1时间.但我遇到的问题是我希望能够完全覆盖产品价格...据我所知,我唯一能做的就是将优惠券应用到购物车.
有没有办法将价格完全覆盖到完全定制的东西?
我正在寻找一种€0,00用文本替换WooCommerce(版本 3.3.x)产品价格的方法,例如“基于合同”。最好在网上商店和电子邮件中可见。由于 WooCommerce 最近的变化,现有的片段不再起作用,例如:
add_filter('woocommerce_get_price_html', 'changeFreePriceNotice', 10, 2);
function changeFreePriceNotice($price, $product) {
if ( $price == wc_price( 0.00 ) )
return 'FREE';
else
return $price;
}
Run Code Online (Sandbox Code Playgroud)
或者
<?php
// Do not copy the opening <?php tag above
// Customize the Free! price output
add_filter( 'woocommerce_variable_free_price_html','wsm_custom_free_price' );
add_filter( 'woocommerce_free_price_html', 'wsm_custom_free_price' );
add_filter( 'woocommerce_variation_free_price_html', 'wsm_custom_free_price' );
function wsm_custom_free_price( $price ) {
// Edit content between single quotes below to desired output
return 'Prepaid Inventory';
}
Run Code Online (Sandbox Code Playgroud)
或者
function my_wc_custom_get_price_html( $price, $product …Run Code Online (Sandbox Code Playgroud)