2015-01-19 4 views
3

장바구니 옆에 머리글에 장바구니 무게를 더하고 싶습니다. 카트의 총 무게. 나는 지금까지왔다 :Woocommerce : 머리글에 카트 무게 추가

<tr class="total-weight"> 
    <?php global $woocommerce; ?> 
    <th><?php _e('Total Weight', 'woocommerce'); ?></strong></th> 
    <td><span class="amount"><?php 
    $total_weight = $woocommerce->cart->cart_contents_weight; 
    $total_weight .= ' '.get_option('woocommerce_weight_unit'); 
    echo $total_weight; 
    ?></span></td> 
</tr> 

이 코드는 카트의 무게를 출력하지만 머리글에 어떻게 추가 할 수 있는지 알 수 없다.

도움 당신은 함수로 코드를 저장하고 표시하기 위해 총 중량이 필요한 곳 ​​단순히 함수를 호출 할 수 크게 될

+1

header.php 파일에 넣으시겠습니까? – Howli

+0

아하, 그게 쉽지 않아, 장바구니에서 여러 개의 파일이 있습니다. 탐색은 Woocommerece에서 생성됩니다. 그것은 그렇게 간단하지 않습니다. – chandan

+1

테마 자체의 header.php 파일을 참조하고 있습니다. – Howli

답변

1

감사하겠습니다. 예 :

function display_weight(){ 
?> 
<tr class="total-weight"> 
    <?php global $woocommerce; ?> 
    <th><?php _e('Total Weight', 'woocommerce'); ?></strong></th> 
    <td><span class="amount"><?php 
    $total_weight = $woocommerce->cart->cart_contents_weight; 
    $total_weight .= ' '.get_option('woocommerce_weight_unit'); 
    echo $total_weight; 
    ?></span></td> 
</tr> 
<?php 
} 
관련 문제