Woocommerce 제품 상세 페이지를 10 % 추가 금액을 추가 woocommerce에 장바구니 버튼에 추가 : -각 제품에
- 내가 여분의 가격을 추가 할. 때 "를 클릭 장바구니 버튼을 추가 할 수 있습니다.
- 을 내가
Woocommerce 제품 상세 페이지를 10 % 추가 금액을 추가 woocommerce에 장바구니 버튼에 추가 : -각 제품에
function calculate_eyehole_fee($cart_object) {
global $isProcessed;
if(!WC()->session->__isset("reload_checkout")) {
foreach ($cart_object->cart_contents as $key => $value) {
$price = $cart_object->cart_contents[$key]['data']->price;
$additionCost = $price * 10/100;
$cart_object->cart_contents[$key]['data']->set_price($price + $additionCost);
}
$isProcessed = true;
}
}
add_action('woocommerce_before_calculate_totals', 'calculate_eyehole_fee', 99);
add_action('woocommerce_before_calculate_totals', 'add_custom_price');
function add_custom_price($cart_object) {
$custom_price = 10; // This will be your custome price
foreach ($cart_object->cart_contents as $key => $value) {
$value['data']->price = $custom_price;
}
}
이 정적을 위해 잘 작동
function calculate_extra10($cart_object) {
global $isProcessed;
if(!WC()->session->__isset("reload_checkout")) {
foreach ($cart_object->cart_contents as $key => $value) {
$price = $cart_object->cart_contents[$key]['data']->price;
$additionCost = $price * 10/100;
$cart_object->cart_contents[$key]['data']->set_price($price + `$additionCost);`
}
$isProcessed = true;
}
}
add_action('woocommerce_before_calculate_totals', 'calculate_extra10', 99);
이 코드를 시도 완전히 제품 가격을 무시할 수 있도록하려면 가치 : 제품 가격 페이지에서 동적 가격을 사용하고 싶습니다 –
이 코드는 제품 가격에 10 %의 수수료가 추가됩니다! –
사용자 정의 hidde를 사용하여 제품 세부 정보 페이지에서 오는 10 %를 의미합니다. n fields –