Saturday 16 September 2017

Add Custom Cart Item Data in WooCommerce


One of the greatest things about WooCommerce is the flexibility it gives you as a store owner. I’m currently working on a side project where I needed to add some custom data to a product when adding it to the cart. Using hooks means I can achieve this quite easily. In the following tutorial I will guide you through the process of adding a field to your product, showing that data in your cart, saving it to the order, and then displaying it to the customer and admin users.
This is an advanced tutorial. You’re best off building this functionality into a custom plugin, but I’ll leave that decision up to you.
Add a Custom Field to Your Product
Firstly, we’ll want to add a custom field to our product. Let’s consider this scenario as our example; you run a store which makes custom engraved wooden signs. You want your customer to be able to enter the text for their engraving into an input field on your product, which is then saved with the order for the production team to start building the sign.
I have set up a simple product 1 to act as the base of our customisable product.
Before the add to cart button, let’s add a simple input field called “Engraving”.
Source: https://managewp.org/articles/16112/add-custom-cart-item-data-in-woocommerce




source https://williechiu40.wordpress.com/2017/09/17/add-custom-cart-item-data-in-woocommerce/

No comments:

Post a Comment