price

WooCommerce product custom discounted price for logged in users

做~自己de王妃 提交于 2021-01-01 06:43:47
问题 I have a question about managing prices in WooCommerce. I have a store only with simple products. Let's say that for all subscribers and customers the regular price of each product is discounted by 10%. This was easy: function custom_price( $price, $product ) { global $post, $blog_id; $post_id = $post->ID; get_post_meta($post->ID, '_regular_price'); if ( is_user_logged_in() ) { return $price = ($price * 0.9); } else{ return $price; } } add_filter( 'woocommerce_get_price', 'custom_price', 10,

WooCommerce product custom discounted price for logged in users

烂漫一生 提交于 2021-01-01 06:40:35
问题 I have a question about managing prices in WooCommerce. I have a store only with simple products. Let's say that for all subscribers and customers the regular price of each product is discounted by 10%. This was easy: function custom_price( $price, $product ) { global $post, $blog_id; $post_id = $post->ID; get_post_meta($post->ID, '_regular_price'); if ( is_user_logged_in() ) { return $price = ($price * 0.9); } else{ return $price; } } add_filter( 'woocommerce_get_price', 'custom_price', 10,

Assign custom field price as product price to specific user role in WooCommerce

心已入冬 提交于 2020-12-12 18:17:50
问题 I created a new role called "Wholesaler". The role works as expected. I also created a custom price field called "Wholesaler price". It also works as expected. I check the user role, if they are assigned as a wholesaler, I give them the custom product price (if it is filled in). I have everything working except I can't figure out the final piece. How do I pull the current product ID, get the wholesale price, and assign it. My functions.php code is below: /* Custom user roles */ add_role(

Change Order item prices in Woocommerce 3

拟墨画扇 提交于 2020-08-23 09:46:05
问题 I need to change the item price in a woocommerce order but everything I found is to changing the price in the cart but this is not what I need because I need to change after the checkout process. Does somebody can give me a clue on how to do that? 回答1: You need to use the new CRUD setters methods introduced with Woocommerce 3: For order object you will use WC_Order methods, For order "line item" you will use WC_Order_Item_Product methods, For both of them you could be also use some WC_Data

Hide Price based on product category in Woocommerce

二次信任 提交于 2020-08-07 07:15:49
问题 In Woocommerce I am trying to hide the product on the archive page and single product page based on category however the condition does not appear to work and just hide all the price whether I set the category or not add_filter( 'woocommerce_variable_sale_price_html', 'woocommerce_remove_prices', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'woocommerce_remove_prices', 10, 2 ); add_filter( 'woocommerce_get_price_html', 'woocommerce_remove_prices', 10, 2 ); function woocommerce