【发布时间】:2019-01-31 03:15:05
【问题描述】:
我想显示一条自定义文本消息,以通知客户他们选择的输入数量(在单击“添加到购物车”按钮之前)。如果所选数量大于现有可用库存数量,则会出现此消息,位于单个产品页面中数量选择的正上方。例如:
Existing Stock Quantity: 2
User Selects: >2
在这种情况下,我想告诉客户类似这样的信息:“您选择的订单数量大于我们现有的库存。预计我们的库存最多会延迟 2 周补货。”
我尝试将自定义代码添加到代码片段中,看起来像这样:
function display_order_quantity_exceeds_stock_quantity_text( $message, $product ) {
if( $product->woocommerce_quantity_input() > $product->get_stock_quantity()) {
$message = "Your selected order quantity is greater than our existing stock. Please expect a delay of up to 2 weeks for our stock to be replenished.";
}
return $message;
}
有谁知道我如何获得 woocommerce_quantity_input 并让它工作?
宁愿通过在代码片段中添加一个函数来获得解决方案,而不是使用 Javascript(如果可能)。
【问题讨论】:
标签: wordpress woocommerce