How to set subcategory in Woocommerce?

You will have to first insert the term as required using wp_insert_term. wp_set_object_terms( $post_id, ‘Lense’, ‘product_cat’, false); This function checks if ‘Lense’ term exist in product_cat or not. If does not exist, then create and assign. Check whether term already exists or not $id = term_exists( ‘canon’,’product_cat’,$parent_id ) //$parent_id is parent term id, in your … Read more

Woocommerce product not appearing in category list page when created programatically [closed]

Try like $post_id = wp_insert_post( array( ‘post_title’ => $items[‘description’], ‘post_content’ => $items[‘detail’], ‘post_excerpt’ => $items[‘description_2’], ‘post_status’ => ‘publish’, ‘post_type’ => “product”, ) ); // Set Product type // wp_set_object_terms( $post_id, ‘simple’, ‘product_type’); wp_set_post_terms( $post_id, ‘simple’, ‘product_type’); // Get parent category returns mixed or objects $category_parent = get_term_by(‘name’, ‘Lense’, ‘product_cat’); // Get child category returns array … Read more

Woocommerce Shop Manager Capabilities

Issue is related to Order Delivery Date for WooCommerce. function orddd_lite_capabilities() { $role = get_role( ‘shop_manager’ ); if( ” != $role ) { $role->add_cap( ‘manage_options’ ); } } Comment out the line //add_action( ‘admin_init’, array( &$this, ‘orddd_lite_capabilities’ ));

populating extra field with woocommerce categories

ok, solution: $args = array( ‘order’ => ‘ASC’, ‘hide_empty’ => $hide_empty, ‘include’ => $ids, ‘posts_per_page’ =>’-1′ ); $product_categories = get_terms( ‘product_cat’, $args ); (isset($_POST[“Cianfrusaglie”])) ? $company = $_POST[“Cianfrusaglie”] : $company=1; echo “<select name=”cat_shop” id=’reg_cat_shop’ class=”dokan-form-control input-md valid”>”; foreach( $product_categories as $category ){ echo “<option “; ?><?php if ($cat_shop == esc_html( $category->name ) ) echo ‘selected’ … Read more

Correct method of reducing the number of images created by WP and Woo together

I would remove the image sizes that you don’t need. function remove_image_sizes() { remove_image_size(‘image-name’); } add_action(‘init’, ‘remove_image_sizes’, 99); Whilst the number of images is a factor, I’d also look at the image compression as this may be a big help in reducing the disk space required: add_filter(‘jpeg_quality’, function($arg){return 70;}); You will need to re-generate your … Read more