Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce

Look into wp_set_object_terms() You could do something along the lines of: wp_set_object_terms( $post_id, ‘exclude-from-catalog’, ‘product_visibility’ ); Getting all posts by status, use Wp_Query. I added the ‘fields’ => ‘ids’ param to limit the query to only ids, rather than gathering whole post objects. On an array of posts that have Draft or Pending as a … Read more

Woocommerce: Get Cart ID

Why this question down-voted? I think it is can be very useful. Unfortunately WooCommerce have not feature like this. But you can: Set cookie with unique id, when user added something to cart Create db table with cookie_cart_id and items, and update this table when user change items in cart. When user create order – … Read more

Is it possible to recalculate cart prices? [closed]

Maybe you need to add : wc_delete_product_transients($post->ID); I did something like this in opther project and thats worked: if (is_user_logged_in()) { add_filter(‘woocommerce_product_variation_get_regular_price’, ‘my_custom_price’, 10, 2); add_filter(‘woocommerce_product_variation_get_price’,’my_custom_price’, 10, 2); } function my_custom_price( $price ) { global $post; // Delete product cached price (if needed) wc_delete_product_transients($post->ID); // Return the new price return $price = ($price * 1.1) … Read more

A mystery 300px image size

Updated Answer After doing more testing, the 300px size only gets generated when I have the official WooCommerce Brands plugin activated. So 300px is the default WooCommerce image size when the standard sizes go undefined. See wc_get_image_size() in \includes\wc-core-functions.php. It seems that at some point WC must have filled in the blank of a missing … Read more

why featured product not updated in postmeta table in woocommerce?

Since 3.0 featured products are marked as featured by being given the featured term that WooCommerce creates in the product_visibility taxonomy. But to tell if a product is featured, instead of checking the terms directly or using get_post_meta() (which wouldn’t work anymore anyway), use the get_featured() method of WC_Product: $product_id = 1; $product = wc_get_product( … Read more