0
クリックするとPlace Order Buttonの動作を変更するためのフックがあるのだろうかと思います。私は、製品選択(すべての利用可能な製品)がCheckoutページにもあるため、注文時に製品を交換/変更しようとしています。Place注文のカスタム動作のためのWoocommerceフック
これまでのところ、私は操作しようとしていましたwoocommerce_checkout_order_review
フック&が失敗しました。
add_action('woocommerce_checkout_order_review', 'remove_woocommerce_product');
function remove_woocommerce_product(){
if (isset($_POST['woocommerce_checkout_place_order'])){
global $woocommerce;
$woocommerce->cart->empty_cart(); // Empty the cart
$selectedproduct = $_POST['selectedproductid']; // Get the selected product
WC()->cart->add_to_cart($selectedproduct); // Insert the selected product in the the cart
return esc_url(wc_get_checkout_url()); // Redirect to Payment Gateway Page
}
}
上記のフックは、Place Orderでトリガされません。おそらく、私のコードに何か問題があるかもしれません。あるいは、間違ったフックが適用されていると思われるかもしれません。何か案は?より詳細な説明については