cart

Set Woocommerce cart item price to zero if the product has already been bought

杀马特。学长 韩版系。学妹 提交于 2019-12-24 09:39:17
问题 I am unable to override price on second time purchase. The use case would be: If a user has already bought product "944" then the price would be 0 for next time orders. Meaning, the customer would pay only for first order of that specific product and it would be free for next orders. Here my code: // Enter the ID of the product that shouldn't be purchased again $no_repeats_id = 944; $no_repeats_product = wc_get_product( $no_repeats_id ); // Get the current product to check if purchasing

Add to cart with custom data from an url using GET method in Woocommerce 3

有些话、适合烂在心里 提交于 2019-12-24 08:23:03
问题 In Woocommerce, I am adding products to cart using the GET method from an URL like: http://example.com/cart/?add-to-cart=10 Now I would like to be able adding at the same time some custom data as a product note like: http://example.com/cart/?add-to-cart=10&note=hinote And then saving that "hinote" value as the cart item data. Once oder is placed, I would like to save that "hinote" in order item data and display it as custom order item data everywhere. Is that possible? Any help is appreciated

Add dropdown to products and display the value on Woocommerce cart

只愿长相守 提交于 2019-12-24 08:19:51
问题 I'm having trouble adding a custom dropdown to the cart meta and displaying it in the cart. The code below works for a number field that is also on the single product page, but not for the dropdown for some reason. Does anyone know why? The code is as follows: // Dropdowns-in-ends starts here add_action( 'woocommerce_before_add_to_cart_button', 'func_dropdown_in_ends'); function func_dropdown_in_ends() { printf( '<div class="class_dropdown_ends"><label for="id_dropdown_one_end">I andre enden

Make WC_Cart add_to_cart method working for guests in Woocommerce

£可爱£侵袭症+ 提交于 2019-12-24 08:02:11
问题 Im trying to get my code to work. Searching for hours now. I found similar questions like this one. But unfortunately noone seems to find a solution. In my custom plugin I want to add a specific item to the WC cart and redirect the user directly to the checkout. As a logged in user it works like a charm but for guests it shows a blank page on checkout (woocommerce_checkout shortcode seems to return nothing in this case). So I came up with a check if the cart iss till empty. Apparently it is

Set a custom shipping rate cost calculated on cart total weight in WooCommerce

痞子三分冷 提交于 2019-12-24 06:49:37
问题 In Woocommerce I have installed a shipping plug in but it calculates shipping per item in cart instead of per order total. What I need is to calculate the shipping cost this way: - First kg is $5 - And $1 by kilo for all others. Is it possible to do it? With the plugin if there is 2 items in cart of 1 kg each, it calculates the shipping as 2 x $5 = $10 Instead what I should need is: $5 (first kilo) + $1 (additional kilo) = $6 (for 2 kg) . I have no response from plugin developer, so looking

Replace specific cart item based on product quantity in Woocommerce

霸气de小男生 提交于 2019-12-24 06:37:14
问题 I am trying to change the cart content based on the quantity of a product in the cart. I only have 5 products in the shop: Product_1 => 1 panel, Product_2 => 12 panels, Product_3 => 18 panels, Product_4 => 30 panels, Product_5 => 60 panels, They are configured as different products, so no bundles, kits or anything. More than one panel products are obviously cheaper than adding a number of single panels separately. Then I have also a custom product that calculates the number of panels needed

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

邮差的信 提交于 2019-12-24 03:08:29
问题 I am creating a membership site and totally created static pages for each Membership plans (have only 3 plans). However, I have added products for each plan and when I hit SELECT PLAN button I redirect to some custom form where I ask users range of info we are going to use to fulfil the plan (same as sneakertub.com). I have written code into the PHP page which will handle SUBMIT action of the form. This PHP file, infopage.php , will process POST data I sent via POST call and stores these all

WooCommerce: Custom cart item counts by product category

ε祈祈猫儿з 提交于 2019-12-24 03:07:24
问题 I found this script that allows me to show cart content total above the shopping cart icon within WooCommerce: <a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a> If there are 100 items in my cart it shows 100. What I really want is to display

Show woocommerce product custom fields under the cart and order item name

风流意气都作罢 提交于 2019-12-23 22:26:48
问题 I have a code that shows custom fields in the "General" tab on the product edit page. After the manager has filled these fields, the data is displayed on the Archive/Category pages and in the Single Product page. Also, these fields are in the cart and on the checkout page. Here is my code: // Display Fields using WooCommerce Action Hook add_action( 'woocommerce_product_options_general_product_data', 'woocom_general_product_data_custom_field' ); function woocom_general_product_data_custom

Which Hook is running after Woocommerce update cart button action

青春壹個敷衍的年華 提交于 2019-12-23 21:05:12
问题 i need to know which hook is running after clicking the update cart button in the cart page . That is in cart page we have 4 button , update cart , continue shopping , proceed to checkout , apply coupon . So i want to know which hook is run after update cart button is clicked . When customer click the update cart button after changing the quantity then i have to run a special function that can change total price in the cart , If some condition met , i will change the total price in the cart ,