php 致电销售触发:低库存通过短代码触发至低于价格位置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 致电销售触发:低库存通过短代码触发至低于价格位置相关的知识,希望对你有一定的参考价值。
<?php
/**
* Adding Low Stock (WooCommerce Sales Trigger) trigger shortcode to Below Price position.
* Required: WooCommerce (https://wordpress.org/plugins/woocommerce/)
* Required: XL WooCommerce Sales Trigger (https://xlplugins.com/woocommerce-sales-triggers/)
* Done for Client 'Brad'
*
* Note: Sales Trigger plugin must be installed otherwise results in PHP Fatal error
*/
add_action( 'woocommerce_single_product_summary', 'theme_xl_setup_wcst_post_data', 1 );
function theme_xl_setup_wcst_post_data() {
global $product;
if ( method_exists( $product, 'get_id' ) && class_exists('WCST_Core') ) {
$wcst_core = WCST_Core::get_instance();
$script_data = $wcst_core->script_data;
if ( ! isset( $script_data['product_type'] ) ) {
$localize_arr = $script_data;
$productObj = XL_WCST_Product::get_instance( $product->get_id() );
$dates = $productObj->sales_date_for_product_variations();
$localize_arr['product_type'] = $productObj->product->get_type();
$localize_arr['product_variation'] = $dates['variations'];
$localize_arr['product_variation_to'] = $dates['end'];
$localize_arr['current_postid'] = $product->get_id();
$localize_arr['utc0_time'] = WCST_Common::get_site_time();
// product stock status
$localize_arr['product_status'] = $productObj->get_stock_status();
// product stock status
$localize_arr['product_backorder_status'] = $productObj->get_backorder_status();
$wcst_core->script_data['settings'] = array();
$wcst_core->script_data['compatibility'] = array();
$localize_arr['currency_pos'] = get_option( 'woocommerce_currency_pos' );
$wcst_core->script_data = $localize_arr;
}
}
}
add_action( 'woocommerce_single_product_summary', 'theme_xlst_position_below_price', 17.2 );
function theme_xlst_position_below_price() {
global $product;
if ( method_exists( $product, 'get_id' ) && class_exists('WCST_Core') ) {
echo do_shortcode( '[wcst_low_stock product_id="' . $product->get_id() . '"]' );
}
}
以上是关于php 致电销售触发:低库存通过短代码触发至低于价格位置的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 查询 - 创建一个触发器,在销售发生后更新库存水平
php 销售触发器:修改XLPlugins的客户端“或”的销售代码段触发器输出
php 触发Joomla插件短代码(在模板中)
php 销售触发器:向Sales Count或Sales Snippet触发数据提取添加更多WC状态。
php WooCommerce旧单产品定位钩 - 用于销售触发(由XLplugins提供)
低代码机器人是如何实现监控库存,并实时通知指定人,仓库管理不再慌乱