Create WooCommerce Product Category Programmatically

To create a taxonomy term programmatically you can use wp_insert_term function. <?php wp_insert_term( $term, $taxonomy, $args = array() ); ?> It has 3 params: $term (int|string) (required) The term to add or update. Default: None $taxonomy (string) (required) The taxonomy to which to add the term. Default: None $args (array|string) (optional) Change the values of … Read more

WooCommerce – Hook after Loading Variation in Admin Edit page?

In woocommerce/includes/class-wc-ajax.php there is a method on the WC_AJAX class responsible for loading variations called load_variations, it contains only one hook, which is a filter, named woocommerce_ajax_admin_get_variations_args which fires early in the method. However if you are looking for something client side, then woocommerce/assets/js/admin/meta-boxes-product-variation.js triggers an event on the success callback of the load_variations function … Read more

Get product link

WooCommerce default customer-complete-order.php email template does not link the order item to corresponding product. You need to use woocommerce_order_item_name filter and update the item name to have link. I just tried below code and it adds the link to order item (product name). Put this code in functions.php file of your theme. Hope this helps: … Read more

Add custom variable to cart content [closed]

I had to do something similar a while ago, this is what was working for me: In the example, the custom input name is “test_field” inside the add to cart form, and this way when you dump the cart_contents, you can see the value somewhere at the end //Store the custom field add_filter( ‘woocommerce_add_cart_item_data’, ‘add_cart_item_custom_data_vase’, … Read more