How can we help? πŸ‘‹

Cross-Sell Products

Display synced Cross-Sell Products on your WooCommerce product page.

Cross-Sell Products are a great way to increase revenue and average order value. Use the following PHP code snippet to display Cross-Sell Products synced via Partbot.

global $product;
echo "<ul class='products columns-3'>";
foreach ($product->get_cross_sell_ids() as $cross_sell_id) {
	$cross_sell = wc_get_product($cross_sell_id);
	$permalink = get_permalink($cross_sell_id);
	echo "<li class='product'>";
	echo "<a href='{$permalink}' target='_blank'>{$cross_sell->get_name()}</a>";
	echo "<p>{$cross_sell->get_price_html()}</p>";
	echo "<p>{$cross_sell->get_image()}</p>";
	echo "<a href='?add-to-cart={$cross_sell_id}' data-quantity='1' class='button product_type_simple add_to_cart_button ajax_add_to_cart' data-product_id='{$cross_sell_id}' data-product_sku='{$cross_sell->get_sku()}' aria-label='Add β€œ{$cross_sell->get_name()}” to your cart' rel='nofollow'>Add to cart</a>";
	echo "</li>";
echo "</ul>";
Make sure to style to match your website theme!
Did this answer your question?