This topic contains 6 replies, has 2 voices, and was last updated by Tom Tom 5 months, 4 weeks ago.

Selected product attribute not showing!

  • I noticed that the selected and added product attribute, e.g., Size: Large, isn’t showing in the mini-cart, and checkout page. The selected attribute’s price is, however, captured and shown.

    Please advise on a fix soon. Thank you.

    Tom

    Hi,

    You can modify in: /wp-content/themes/alto/headers/includes/mini-cart-sidebar.php

    We will check on next version.

    Thank and best regards,
    Tom

    It isn’t just the “/altotheme-child/headers/includes/mini-cart-sidebar.php”, but also “/altotheme-child/woocommerce/cart/cart.php” and “/altotheme-child/woocommerce/checkout/review-order.php”. As a reminder, altotheme-child is my active theme.

    I managed to add the following lines of code (in bold) for “mini-cart-sidebar.php”, between lines 18 and 19.

    <?php
    $product_title = $_product->get_title();
    echo ‘‘ . apply_filters(‘woocommerce_cart_widget_product_title’, $product_title, $_product) . ‘‘;
    if ( $_product->is_type( ‘variation’ ) && is_array( $cart_item[‘variation’] ) ) :
    echo ‘<div>’ .wc_get_formatted_variation( $cart_item[‘variation’], true, true ). ‘</div>’;
    endif;

    echo ‘<div class=”cart_list_product_quantity”>’ .wc_price($_product->get_price()). ‘ × ‘ .$cart_item[‘quantity’]. ‘</div>’;
    ?>

    As for the other 2 remaining templates, I’ll probably include a snippet into the active theme’s functions.php. This is because both templates have echo apply_filters( 'woocommerce_cart_item_name', which I can use to insert a newline with the product’s variation(s).

    I’ll update that next.

    By the way,
    <?php echo WC()->cart->get_item_data( $cart_item ); ?>
    isn’t working for me.

    Hence, I’ve to replace it with
    if ( $_product->is_type( ‘variation’ ) && is_array( $cart_item[‘variation’] ) ) :
    echo ‘<div>’ .wc_get_formatted_variation( $cart_item[‘variation’], true, true ). ‘</div>’;
    endif;

    Strange, isn’t it?

    Tom

    Hi,

    I’m not a dev, but code: <?php echo WC()->cart->get_item_data( $cart_item ); ?> maybe error.
    Hope you solved your problem.

    Best regards,
    Tom

    This reply has been marked as private.
    Tom

    Hi,
    http://prntscr.com/fc74rz
    i tried use echo $woocommerce->cart->get_item_data($cart_item);
    It is working ok.
    Could You check again.

    Best regards,

    LeeBrous’s Dev

You must be logged in to reply to this topic.