2016-08-20 17 views
0

我想在店面主題的擡頭購物車的定價之前添加文本「您的購物車:」,我嘗試編輯並將其添加到inc /在如何在Storefront主題woocommerce的擡頭購物車中的價格之前添加自定義文本

<?php 
function storefront_cart_link() { 
<span class="amount">ADDED HERE<?php echo "AND HERE ALSO" . wp_kses_data(WC()->cart->get_cart_subtotal()); ?></span> 
}?> 

儘管它出現在前端,直到網站負載woocommerce /店面,woocommerce-模板的functions.php線72,裝載完成後,該文本只是消失。 請建議如何做到這一點。

運行WP V4.6

回答

1

它會顯示您的購物車文字,如果你將其添加外錨標記像下面。

function storefront_cart_link() { 
     ?> 
      <span style="float:left;">Your Cart :</span> 
      <a class="cart-contents" href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>" title="<?php esc_attr_e('View your shopping cart', 'storefront'); ?>"> 
       <span class="amount"><?php echo wp_kses_data(WC()->cart->get_cart_subtotal()); ?></span> <span class="count"><?php echo wp_kses_data(sprintf(_n('%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront'), WC()->cart->get_cart_contents_count()));?></span> 
      </a> 
     <?php 
    } 
+0

感謝@Jatin回答,它在桌面上運行良好,但在移動設備上,您的購物車:文本出現在標題上,如何將其隱藏在移動設備上。 –

+0

您可以添加您喜歡的課程,然後使用媒體查詢將其隱藏在移動設備中。 '<跨度類=「cart_text」>你的購物車:' 所以它的CSS會是這樣在正常屏幕 '.cart_text {浮動:左;}' 和用於移動設備可以使用像這樣。 '@media(max-width:768px){。cart_text {display:none;}}' 在位於storefront \ assets \ sass \ woocommerce \ woocommerce的woocommerce.css末尾添加上面的代碼行.css 而且它對手機和桌面屏幕來說工作得很好:) –

相關問題