Ceの右フックがwoocommerce_before_calculate_totals
です。どのプラグインでも
add_filter('woocommerce_before_calculate_totals', 'custom_cart_items_prices', 10, 1);
function custom_cart_items_prices($cart_object) {
if (is_admin() && ! defined('DOING_AJAX'))
return;
foreach ($cart_object->get_cart() as $cart_item) {
// get the product id (or the variation id)
$id = $cart_item['data']->get_id();
// GET THE NEW PRICE (code to be replace by yours)
$new_price = 500; // <== Add your code HERE
// Updated cart item price
$cart_item['data']->set_price($new_price);
}
}
コードは、あなたのアクティブな子テーマ(またはテーマ)のfunction.phpファイルに行くか:しかし、あなたは下のフック機能で新しい価格を取得するためのコードを完了する必要が(置き換え)しますファイル。
このコードは、WooCommerceバージョン3以降で動作確認されています。しかし、コードを書いていないので、私はセッションから新しい価格を得るためにそれをテストすることはできません...