WooCommerce
December 18, 2020

Reordering Cross-Sells and Up-Sells in WooCommerce

Cross-sells and Up-sells in WooCommerce are a very powerful tool to give suggestions to your customers. You might know that most people who buy product A will probably need product B as well, and you want the customer to know that. How do you do it? You use cross-sells and up-sells.

These products are shown respectively on the product page and on the cart page. They show like they would show on the Shop page in most cases. The only difference would be their order.

By default, cross-sells and up-sells are randomly sorted. But what if you want to change that? Maybe you want to show them by publish date, or by ID. As usual, there are filters for it!

That being said, let’s add the following code to the main file of a plugin or a theme’s function.php file (keeping in mind that it’s always best to create a child theme instead of altering a functions.php file):

Related Post


Get Currency symbol WooCommerce

You can get current currency in woocommerce using get_woocommerce_currency_symbol(); function.

Add Product to Cart Programmatically Woocommerce

We can add product to WooCommerce cart using add_to_cart() function with $product_id. Code goes in function.php file of your active child theme (or active theme).

How to Change “Return to Shop” Button text in WooCommerce

Change “Return to Shop” Button text in WooCommerce a WordPress plugin this is quit easy to change it using gettext filter. If you are not using shop or name it something like back to home or store. Code goes in function.php file of your active child theme (or active theme).

WooCommerce Remove the Additional Information and Order Notes fields

We can remove the Additional Information and Order Notes fields in WooCommerce checkout page with 2 filters that you add to functions.php file.

Get product details from $product object WooCommerce

I am publish this article for get values from WooCommerce $product object. You can get all information of product from $product object. When we have $product object. Get $product object by $product_id. Get $order object by $order_id. Get products from $cart object.

Only Allow 1 Product in the Cart WooCommerce

We can set add to cart limit on WooCommerce cart using woocommerce_add_to_cart_validation filter. Add below code on functions.php file to limit your WooCommerce Cart to just 1 product.


Leave a Reply

Your email address will not be published. Required fields are marked *