PHP Add products to cart with WooCommerce Addons

The WooCommerce Cart add_to_cart function takes a parameter for cart_item_data. To make this work, you simply need to pass the addon data to add_to_cart. Something like this: $addons = array( array( “name” => “Size”, “value” => “2.5×7”, “price” => 0, “field_name” => “5186-0”, “field_type” => “multiple_choice”, “id” => “1683555538”, “price_type” => “flat_fee” ), array( “name” … Read more

How to get all child categories of current parent category in product detail page of woocommerce? [closed]

This is how you display all child terms of a parent term: $term_id = 8; // id of your clothes category $taxonomy_name=”your_taxonomy”; // e.g. ‘category’ $termchildren = get_term_children( $term_id, $taxonomy_name ); if ( !empty($termchildren) ) { foreach ($termchildren as $termchild) { $term = get_term_by( ‘id’, $child, $taxonomy_name ); // Do things } } See https://developer.wordpress.org/reference/functions/get_term_children/