Wordpress 的 Woocommerce:如何修改订单号/ID? [英] Woocommerce for Wordpress: How to modify the order number/id?

查看:54
本文介绍了Wordpress 的 Woocommerce:如何修改订单号/ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 WooCommerce 实施到我的网店,并已连接 CorvusPay 网关以进行在线支付.

I have implemented WooCommerce to my webshop and have connected a CorvusPay gateway for online payment.

现在我们遇到的问题是 Corvus 要求我的订单号包含字符(大写和小写)以及数字.

Now the problem that we are having is that Corvus requires my order numbers to contain characters (uppercase and lowercase) along with numbers.

我已经看到并尝试了许多关于如何在 Wordpress 中更改我的订单号的插件和过滤器,但是当订单正在处理并发送到 Corvus 时,该号码仍然是相同的旧帖子 ID.

I have seen and tried many plugins and filters on how to change my order numbers inside Wordpress, but whilst the order is being processed and sent to Corvus the number is still the same old post ID.

我知道 WooCommerce 使用 Wordpress 帖子 ID 创建初始订单号,但我该如何更改?

I am aware that WooCommerce uses Wordpress post IDs to create the initial order numbers, but how can I change this?

我如何修改 WooCommerce 以便它使用特定的订单号生成方法,即我希望订单号是例如Kr-12345"和不是12345".

How can I modify WooCommerce so that it uses a specific method of order number generation, that is I'd like the order numbers to be e.g. "Kr-12345" and not "12345".

我需要一种方法来更改其编号生成方法,而不是使用 Sequential Order Numbers 之类的插件,因为它只会更改我的 Wordpress 页面中的编号.

I need a way to change its method of number generation and not use a plugin like Sequential Order Numbers since that just changes the numbers in my Wordpress page.

推荐答案

你可以使用 woocommerce_order_number 钩子来过滤你想要的值.本指南解释如何使用它来简单地添加前缀和后缀.

You can use the woocommerce_order_number hook to filter the value however you want. This guide explains how to use it for simply adding a prefix and suffix.

add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number' );

function change_woocommerce_order_number( $order_id ) {
    $prefix = 'VK/';
    $suffix = '/TS';
    $new_order_id = $prefix . $order_id . $suffix;
    return $new_order_id;
}

所以看起来这可以满足您的需求.如果不需要,可以删除后缀,或者对 $new_order_id 的格式进行必要的调整.

So it looks like this would do what you're wanting. You could just remove the suffix if you don't need it, or make any necessary adjustments to the format of $new_order_id.

要记住的另一件事是,如果您使用像 PayPal 这样的插件,WooCommerce 它有一个选项来设置内置的发票前缀.

Another thing to keep in mind is that if you're using a plugin like PayPal for WooCommerce it has an option to set an invoice prefix built in.

这篇关于Wordpress 的 Woocommerce:如何修改订单号/ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆