Help! Get up-sell thumbnail
-
Hey all,
I have been playing around with this code which adds a check box for adding to cart a simple product – this works great! What I am trying to add on to this is grabbing the Up-Sell product thumbnail.
I found that adding
<?php the_post_thumbnail( 'shop_thumbnail' ); ?>
between// create the checkbox form fields and add them before the cart button add_action( 'woocommerce_before_add_to_cart_button', 'action_woocommerce_before_add_to_cart_form', 10, 0 ); function action_woocommerce_before_add_to_cart_form(){ global $woocommerce, $product; // get the product up-sells $upsells = $product->get_upsells(); // store the number of up-sells and pass it on to the add-to-cart hook ?> <input type="hidden" name="upsells_size" value="<?php echo(sizeof($upsells)); ?>"> <div id="wb-upsell-div">
<?php the_post_thumbnail( 'shop_thumbnail' ); ?>
<?php // iterate through all upsells and add an input field for each $i = 1; foreach( $upsells as $value ){ $product_id = $value; ?> <input id="wb-upsell-checkboxes" type="checkbox" name="upsell_<?php echo($i) ?>" value="<?php echo($product_id); ?>"><?php echo( '<a href="' . esc_url( get_permalink( $product_id )) . '" target="_blank">' . get_the_title( $product_id ) . "</a>". "????($" . get_post_meta( $product_id, '_regular_price', true) . ")"); ?><br> <?php $i++; } ?> </div> <?php }
Visually what happens is this: https://imgur.com/UOsTdyT
And I am trying to call the Up-Sell sidebar thumbnail instead – any help would be greatly appreciated for changing the
<?php the_post_thumbnail( 'shop_thumbnail' ); ?>
to get the upsell thumbnail over the current product pages product thumbnail.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Help! Get up-sell thumbnail’ is closed to new replies.