WooCommerceで、返品するクライアントが受け取った注文の製品SKUを変更しようとしています。
現在、私は現在のコードを使用していますが、動作していないようです。返品するクライアントの製品のSKU番号を返信する
私は2種類の製品を持っています。 idが5836
の製品は、通常の製品であり、他方はサブスクリプションです。
これは私のコードです:
function action_woocommerce_thankyou($order_id) {
// Let's get the order details
$order = wc_get_order($order_id);
// Customer who made the purchase
$user_id = $order->get_user_id();
// Now get order count for the customer
$order_count = wc_get_customer_order_count($user_id);
$items = $order->get_items();
foreach ($order->get_items() as $item_id => $item) {
$product_name = $item['name'];
$product_id = $item['product_id'];
$product_variation_id = $item['variation_id'];
if ($order_count > 1) {
// Returning customer...
if ($product_id == '5836') {
update_post_meta($order_id['product_id'], '_sku', $ANT0001);}
else {
// Returning customer...
update_post_meta($order_id['product_id'], '_sku', $ANT0002);}
} else {
// New customer...
}
}
}
add_action('woocommerce_thankyou', 'action_woocommerce_thankyou', 10, 1);
こんにちは、私は最後の2日間はベッドで本当に病気です。すぐに私はより良くなり、それをテストできるようになることを願っています。あなたの答えをどうもありがとう。私は、現在の注文SKUだけを変更し、woocommerce製品SKUは変更しないようにする必要があります。私が問題を抱く前に、それは製品SKUを乱用していましたが、注文SKUは邪魔していませんでした。 – Dimijazz