카트의 가격과 부분합을 표시하는 문자열을 필터링해야합니다. 언급 한 링크에서 실제 가격을 변경하는 방법에 대해 논의했습니다. 귀하의 경우 실제 가격을 나중에 설정할 때까지 은 $ 0입니다. 이 카트가 너무 합계를 위해 아마 필터입니다, 그러나 이것은 시작해야한다 : 사용자 정의로 설정 한
물론
add_filter('woocommerce_cart_item_price', 'so_38057349_cart_item_price', 10, 3);
function so_38057349_cart_item_price($price, $cart_item, $cart_item_key) {
if ($cart_item[ 'data' ]->price == 0) {
$price = __('Special Order', 'yourtheme');
}
return $price;
}
add_filter('woocommerce_cart_item_subtotal', 'so_38057349_cart_item_subtotal', 10, 3);
function so_38057349_cart_item_subtotal($subtotal, $cart_item, $cart_item_key) {
if ($cart_item[ 'data' ]->price == 0) {
$subtotal = __('To be determined', 'yourtheme');
}
return $subtotal;
}
add_filter('woocommerce_order_formatted_line_subtotal', 'so_38057349_order_item_subtotal', 10, 3);
function so_38057349_order_item_subtotal($subtotal, $item, $order) {
if (isset($item[ 'line_subtotal' ]) && $item[ 'line_subtotal' ] == 0) {
$subtotal = __('To be determined', 'yourtheme');
}
return $subtotal;
}
,이 또한 0 가격으로 모든 제품에 적용됩니다 아마뿐만 아니라 사람 내장되어 있으므로 여기서 제공 한 것보다 더 많은 조건부 논리가 필요할 수도 있습니다.
귀하의 의견을 따르십시오 .... woocommerce_order_amount_total
은 총 숫자이며 표시된 html이 아닙니다. cart-totals.php
템플릿에서 호출되는 함수를 볼 수 있습니다.
function so_38057349_woocommerce_cart_subtotal($cart_subtotal, $compound, $cart) {
if($cart->subtotal == 0){
$cart_subtotal = __('Order subtotal to be determined', 'yourtheme');
}
return $cart_subtotal;
};
add_filter('woocommerce_cart_subtotal', 'so_38057349_woocommerce_cart_subtotal', 10, 3);
// define the woocommerce_order_amount_total callback
function so_38057349_woocommerce_order_amount_total($order_total) {
if(WC()->cart->get_total() == 0){
$order_total = __('Order total to be determined', 'yourtheme');
}
return $order_total;
};
add_filter('woocommerce_cart_totals_order_total_html', 'so_38057349_woocommerce_order_amount_total');
업데이트 스크린 샷 : 헬가의 대답에 확대
헬가 정말 고마워요. 정확하게 필요한 것입니다. 귀하의 사례를 확대하여 장바구니 및 결제 페이지도 보호합니다! – radug
내 편집을 확인하십시오. 질문의 오류와 유사하게 'woocommerce_order_amount_total'는 HTML 문자열이 아닙니다. – helgatheviking