corporalpoon
corporalpoon

Reputation: 229

Get Woocommerce Cart Product Image Url So I can use it as background image instead

In cart.php we have:

<td class="product-thumbnail" style='background:url(<?php ?>)'>
                            <?php
                                $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );

                                if ( ! $product_permalink ) {
                                    echo $thumbnail;
                                } else {
                                    printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail );
                                }
                            ?>
                        </td>

Is there a way to get the url from that so I can use a background image on the td element instead of the image tag inside?

Upvotes: 2

Views: 7484

Answers (1)

corporalpoon
corporalpoon

Reputation: 229

Was able to get it to work using

<?php echo get_the_post_thumbnail_url($product_id);?>

If for whatever reason, this isn't the best way to solve this problem, please share.

Thanks.

Upvotes: 7

Related Questions