2016-09-09 2 views
0

저는 Wordpress 및 Woocommerce 플러그인을 사용하여 전자 상거래 웹 사이트를 개발하고 있습니다. wishlist에 제품을 추가하기 위해 yin Woocommerce 위시리스트 플러그인을 설치했는데, 표시 단위 제품 원가, 장바구니에 추가 버튼 및 제품 이미지, **** 위시리스트 **에 추가 된 총 제품 원가를 표시하고 싶습니다. 장바구니 버튼도 ** 도와주세요. 미리 감사드립니다.표시 방법 yith woocommerce wishlist plugin을 사용하여 위시리스트에 추가 된 총 상품 원가?

답변

0

몇 가지 위시리스트 플러그인이 있기 때문에 어떤 위시리스트 플러그인을 사용하고 있는지 확실하지 않습니다.

그러나 나는 이것을 위해 YITH Woocommerce Wishlist plugin을 사용하는 동안 해결책을 작성했습니다. 그 코드가 여기에 있으면 도움이된다.

function tnc_wishlist_summary_cart(){ 
    global $woocommerce; 
    $wl_items = YITH_WCWL()->get_products(); 
    $product_price = 0; 
    foreach ($wl_items as $key => $item) { 

     $the_product = wc_get_product($item['prod_id']); 
     $product_price += $the_product->get_price(); 

     if(isset($_REQUEST['add_all_to_cart'])){ 
      $woocommerce->cart->add_to_cart($item['prod_id']); 
     } 
    } 
    $output = 'Total Price: '.$product_price; 
    $output .= "<a href='?add_all_to_cart'>Add All to Cart</a>"; 
    return $output; 
} 
add_shortcode('tnc-wishlist-summary', 'tnc_wishlist_summary_cart'); 

이 코드를 functions.php 또는 독립 실행 형 플러그인에 넣고 위시리스트 페이지에 다음 단축 코드를 넣으십시오.

[tnc-wishlist-summary] 

총 가격과 모두를 장바구니에 추가하는 링크가 출력됩니다. 아니 스타일. 필요에 따라 스타일을 지정해야합니다.

감사

1

이 YITH Woocommerce 위시리스트 플러그인으로 전체 제품 비용을 표시하려면 jQuery로이 작업을 수행 할 수 있습니다

var myArray = $(".wishlist_table .amount"); // Recover all product cost 
var result = 0; 
for (var i = 0; i<myArray.length; i++) { 
    result += parseFloat(myArray[i].childNodes["0"].data); // Make the sum 
} 

$("#som").text(result); // Place total in a HTML element - my ID is "som" but no matter what it is 

$(".remove_from_wishlist").live('click', function(){ // When user remove item with AJAX   
    var href = $(this).attr('href'); // Find parent 
    href = href.replace(/\D/g,''); 
    var arrayTo = $('#yith-wcwl-row-'+href+' .amount').text(); 
    arrayTo = parseFloat(arrayTo.replace(/\u20ac/g, '')); // u20ac is unicode character for euro sign but works with just 'D' instead 
    var recoverTotal = $("#som").text(); // Recover the total 
    var result2 = recoverTotal - arrayTo; 
    $("#som").text(result2); // Display the final result 
}); 

당신은 단축 코드 기능이 코드를 삽입해야합니다. 그것은 나를 위해 작동합니다.

관련 문제