• I’m trying to figure out how to add just 1 line of a custom attribute on a simple product to appear under the title in the Cart page. I have a flooring store set up now, each product has 10+ attributes, but one “Sq/ft Per Box” is one of the most important which should follow into showing on the cart so ideally it appears right under the name. Right now I’ve only found 1 solution which did not work because it added ALL of the attributes to the cart and oddly enough removed them from the “additional info” tab.

    I’m working inside the cart.php file and have been able to add the extra line under the title, but I am not sure how to pull in the attribute reference to show what the inputted attribute is. Basically I added a line of text saying “Sq/ft Per Box:” and nothing appears after, also the issue with how I did it is that will appear no matter what product appears, not just if the product has that attribute.

    Any help appreciated, I can add more info if need be. Trying to be as descriptive as possible.

    https://www.ads-software.com/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    Are you talking about a variable product? Do you have an example URL?

    Thread Starter iamjohnwhite

    (@iamjohnwhite)

    We want to accomplish the same concept of a variable product where it would add the users selection under the product name, yes. But, we are stuck to only creating Simple Products due to our Modern Retail POS Software integration.

    Product to test:
    product
    Under additional info, we have Sq/ft Per Box as an attribute line filled in with 19.69. That 19.69 would ideally populate into the cart

    This is the code I currently have inputed

    <td class="product-name">
    						<?php
    							if ( ! $_product->is_visible() )
    								echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key );
    							else
    								echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', $_product->get_permalink(), $_product->get_title() ), $cart_item, $cart_item_key );
    
    							// Meta data
    							echo WC()->cart->get_item_data( $cart_item );
    
                   				// Backorder notification
                   				if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) )
                   					echo '<p class="backorder_notification">' . __( 'Available on backorder', 'woocommerce' ) . '</p>';
    
    						?><br>
                            <span class="pa_sqft-per-box"><span class="attribute-label">Sq/ft Per Box :  </span> <span class="attribute-value"></span></span>
    
    					</td>

    This is how it appears in cart
    cart image

    Plugin Contributor Mike Jolley

    (@mikejolley)

    So this is custom. Maybe look at WC product addons, or https://github.com/mikejolley/woocommerce-product-gift-wrap to see how to take posted data and show it on your cart.

    Thread Starter iamjohnwhite

    (@iamjohnwhite)

    Awesome, Thanks Mike. I’ll update this thread if I am able to come up with a solution for anyone else looking to do the same. Appreciate the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add single attribute to cart page?’ is closed to new replies.