How to Display All Products Purchased by User
Before diving into this tutorial I recommend you to make a look at order items and my account menu tutorials.
And below on the screenshot you can see what we are going to create.
Welcome to a complete tutorial about WooCommerce order items. Here we are going to talk about how to work with order items in code and then I have a very interesting real life example for you.
WooCommerce REST API: Create Products with Attributes
Before all I also recommend you to check my basic WooCommerce REST API tutorial, where we just created and updated some simple products.
Right now I am going to show you two more specific examples. Two – because there are two types of attributes in WooCommerce – custom attributes and the ones that created in Products > Attributes menu (those are technically taxonomies).
Create and Update Products with WooCommerce API
Recently I was publishing and updating the tutorials about WordPress REST API, how to create a post, how to add a featured image and so on. But did you know that WooCommerce has its own API which is build on the base of a regular WordPress REST API but allows to do much more things and also simplifies the work with the other ones.
In this tutorial we are going to dive into actual examples of working with WooCommerce API, I will show examples of creating and updating products, and also we will try to search them by SKU and delete them.
One more thing – I am a big fan of using WordPress HTTP functions like
wp_remote_request(), so we are going to use them below. So no additional steps are needed like installation of a PHP library or anything else.
Override Product Prices in Cart
In this tutorial I will show you how we can override prices of the products that are already in the Cart with the help of
woocommerce_before_calculate_totals action hook and cart object.
Here we are going to deal with products that have already been added to cart, if you would like to add products to the cart with a custom price, I can recommend you this example.
Below we are going to set the same price ($10) for every product in the cart programmatically.