Woocommerce – remove sale price field from dashboard [closed]

You cannot remove the field using a code but you can disable using the sale price across the store. To disable sale price function custom_wc_get_sale_price( $sale_price, $product ) { return $product->get_regular_price(); return $sale_price; } add_filter( ‘woocommerce_get_sale_price’, ‘custom_wc_get_sale_price’, 50, 2 ); add_filter( ‘woocommerce_get_price’, ‘custom_wc_get_sale_price’, 50, 2 ); To hide this field, you can use a CSS … 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

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

How can i create a WooCommerce product programatically or using sql query?

This will give you a base to start: function generate_simple_product() { $name=”My Product Name”; $will_manage_stock = true; $is_virtual = false; $price = 1000.00; $is_on_sale = true; $sale_price = 999.00; $product = new \WC_Product(); $image_id = 0; // Attachment ID $gallery = self::maybe_get_gallery_image_ids(); $product->set_props( array( ‘name’ => $name, ‘featured’ => false, ‘catalog_visibility’ => ‘visible’, ‘description’ => … Read more