【问题标题】:Adding Sequential numbers in woocommerce for each order separated by product在 woocommerce 中为按产品分隔的每个订单添加序列号
【发布时间】:2019-10-15 22:45:38
【问题描述】:

我有一个销售数字邮箱号码的网站,目前只有一个城市,所以我使用自定义订单号插件将订单号自动更改为序列号,以匹配我可以提供的邮箱号。

现在我要再添加 2 个城市,我想为它们创建一个单独的编号系统,因为每个城市的邮箱都以数字 1200 开头,所以我将无法提供 2 个编号为 1200 的邮箱,例如 2如果我使用自定义订单号,则为城市。

有解决办法吗?

我唯一的想法是为每个城市创建具有不同 WP 安装的子域

应该是这样的

Product A = Numbers start from 1200, +1 added for each sale
Product B = numbers start from 1200, +1 added for each sale
Product C = numbers start from 1200, +1 added for each sale

【问题讨论】:

    标签: woocommerce hook-woocommerce


    【解决方案1】:

    尝试查看您的订单 ID 的前缀或后缀,这将表明它是为哪个城市购买的

        add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number', 1, 2);
    
        function change_woocommerce_order_number( $order_id, $order ) {
            $prefix = '#CITY-';
            // you will need to get your city as a variable to pass in to priffix 
            $suffix = '-' . date(Y); 
            // You can use either one of $order->id (or) $order_id
            // Both will work
            return $prefix . $order->id . $suffix;
        }
    

    【讨论】:

      猜你喜欢
      • 2015-08-14
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      • 1970-01-01
      • 2013-09-29
      • 1970-01-01
      • 2018-04-10
      • 1970-01-01
      相关资源
      最近更新 更多