price

Add a checkbox on single product pages that adds an additional cost in Woocommerce

眉间皱痕 提交于 2019-11-28 14:14:21
In woocommerce, I am using the following code to display an input text field on admin product edit pages, that allow me to add an additonal pricing option to the product: add_action( 'woocommerce_product_options_pricing', 'wc_cost_product_field' ); function wc_cost_product_field() { woocommerce_wp_text_input( array( 'id' => 'repair_price', 'class' => 'wc_input_price short', 'label' => __( 'Repair Cost', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')' ) ); } add_action( 'save_post', 'wc_cost_save_product' ); function wc_cost_save_product( $product_id ) { // stop the quick edit

Dynamic cart item pricing not working on orders in WooCommerce 3.0+

断了今生、忘了曾经 提交于 2019-11-28 14:09:00
I am using WooCommerce 3.0+ and I have set the product price on a certain page. $regular_price = get_post_meta( $_product->id, '_regular_price', true); $buyback_percentage = get_post_meta( $_product->id, '_goldpricelive_buy_back', true); $fixed_amount = get_post_meta( $_product->id, '_goldpricelive_fixed_amount', true); $markedup_price = get_post_meta( $_product->id, '_goldpricelive_markup', true); $buyback_price = ($regular_price - $fixed_amount)/(1 + $markedup_price/100) * (1-$buyback_percentage/100); $_product->set_price($buyback_price); The price is updating on my cart but when I click on

woocommerce change position of price

五迷三道 提交于 2019-11-28 12:56:28
问题 I get this error when trying to render the product price before the main content on the page. Fatal error: Uncaught Error: Call to a member function get_price_html() on string in /wp-content/plugins/woocommerce/templates/single-product/price.php:27 Here is my code: //the remove action works fine remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10); //this breaks it add_action('woocommerce_before_main_content', 'woocommerce_template_single_price', 40); I

Cart item price calculation, based on chosen “days” custom field in Woocommerce

坚强是说给别人听的谎言 提交于 2019-11-28 07:48:37
问题 In Woocommerce, I use custom fields to calculate the price of a product, based on this thread code: Display product custom fields as order items in Woocommerce 3. // Add a custom field before single add to cart add_action('woocommerce_before_add_to_cart_button', 'custom_product_price_field', 5); function custom_product_price_field() { echo '<div class="custom-text text"> <h3>Rental</h3> <label>Start Date:</label> <input type="date" name="rental_date" value="" class="rental_date" /> <label

Set product sale price programmatically in WooCommerce 3

ε祈祈猫儿з 提交于 2019-11-28 01:16:15
问题 I have a Woocommerce store set up with various product categories. I want to apply a 20% discount to all products, which belong to the product category Cuckoo For now all I'm trying to achieve is set a sale price in my functions.php It tried as follows: /* * For a specific date, 20% off all products with product category as cuckoo clock. */ function cuckoo_minus_twenty($sale_price, $product) { $sale_price = $product->get_price() * 0.8; return $sale_price; }; // add the action add_filter(

Dynamic cart item pricing not working on orders in WooCommerce 3.0+

南楼画角 提交于 2019-11-27 19:32:23
问题 I am using WooCommerce 3.0+ and I have set the product price on a certain page. $regular_price = get_post_meta( $_product->id, '_regular_price', true); $buyback_percentage = get_post_meta( $_product->id, '_goldpricelive_buy_back', true); $fixed_amount = get_post_meta( $_product->id, '_goldpricelive_fixed_amount', true); $markedup_price = get_post_meta( $_product->id, '_goldpricelive_markup', true); $buyback_price = ($regular_price - $fixed_amount)/(1 + $markedup_price/100) * (1-$buyback

Display the discounted price and percentage on Woocommerce products

泪湿孤枕 提交于 2019-11-27 13:17:02
问题 On the image below, it shows the discounted price and percentage I found no custom code searching that has this feature. I am using the code below to display the discounted price, but the price is not formatted (the currency symbol and the decimals are missing): add_filter( 'woocommerce_get_price_html', 'modify_woocommerce_get_price_html', 10, 2 ); function modify_woocommerce_get_price_html( $price, $product ) { if( $product->is_on_sale() && ! is_admin() ) return $price . sprintf( __('<p

Move the variation price location in WooCommerce

被刻印的时光 ゝ 提交于 2019-11-27 09:38:35
I'm have started building an e-shop in Wordepress with WooCommerce plugin. I added some products with variations and I noticed that the price is displayed after attributes select fields. Is it possible to move the price between Title and short description as for simple products? The url of one product is: http://www.roubinisideas.com/test2/product/uncategorized/vintage/ Update (on January 2018) : avoiding availability repetitions (bug solved) This is possible and it's is based on this answer that I have maid: Here I have updated the jQuery code to take into account when a variation is set by

Set cart item price from a hidden input field custom price in Woocommerce 3

杀马特。学长 韩版系。学妹 提交于 2019-11-27 09:37:53
In Woocommerce, I used jQuery to calculate a custom price on a single product pages, and now need to pass this value to the cart. The desired behavior is to pass the new price retrieved from the hidden field to the cart item price. Here is my actual code: // Hidden input field in single product page add_action( 'woocommerce_before_add_to_cart_button', 'custom_hidden_product_field', 11, 0 ); function custom_hidden_product_field() { echo '<input type="hidden" id="hidden_field" name="custom_price" class="custom_price" value="">'; } // The code to pass this data to the cart: add_action(

Replace price range handling default variation displayed price in Woocommerce 3

二次信任 提交于 2019-11-27 09:23:06
On our woocommerce website I am trying to update the displayed price based on the variations the customer selects from dropdown menus as shown here: I used a php function that had been submitted in another answer by LoictheAztec: Replace the Variable Price range by the chosen variation price in WooCommerce 3 add_action( 'woocommerce_before_single_product', 'move_variations_single_price', 1 ); function move_variations_single_price(){ global $product, $post; if ( $product->is_type( 'variable' ) ) { // removing the variations price for variable products remove_action( 'woocommerce_single_product