【发布时间】:2019-09-13 16:58:55
【问题描述】:
通过 WooCommerce,我使用 WooCommerce 预订和 WooCommerce 强制销售插件。
我想使用 WooCommerce Force Sells 为预订中的每个人数添加一件强制销售的商品。
Woocommerce 的家伙已经提供了一个 sn-p 来添加到 functions.php 中,它可以修改 Force Sells 的行为。使用此 sn-p,您可以设置要添加的副产品的固定数量 (1):
// only add one force sell item per product no matter how many of the original product are added
function my_wc_force_sell_add_to_cart_product( $product ){
$product['quantity'] = 1;
return $product;
}
add_filter( 'wc_force_sell_add_to_cart_product', 'my_wc_force_sell_add_to_cart_product' );
// when a synced force sell product is updated always set it to 1
function my_wc_force_sell_update_quantity( $quantity, $product ){
return 1;
}
add_filter( 'wc_force_sell_update_quantity', 'my_wc_force_sell_update_quantity' );
我想做的:用一个检索预订中指定人数的函数替换固定数量 (1)。
任何帮助都会很棒。
【问题讨论】:
标签: php woocommerce woocommerce-bookings