cart

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

WooCommerce Get Order Product Details Before Payment in Plugin

[亡魂溺海] 提交于 2019-11-27 18:42:00
问题 I need to display order details from cart before payment in plugin. I work on one plugin what connect woocommerce and an payment API and there I need to send array of product details like product ID, name, description, quantity and individual amount. My problem is that I can't find right hook to get all data properly. How can I get this data? Thanks UPDATE Here is update based on anwers for everyone who need it: add_action('woocommerce_checkout_process', 'woocommerce_get_data', 10); function

Save cart on the current session

谁都会走 提交于 2019-11-27 17:03:23
问题 I'm building a wordpress ecommerce site with the woocommerce plugin, it turns that when an user gets logged in and add products to his cart, but the user don't want to proceed to the checkout process, the user prefers to logout and continue with the checkout process later... when the user comes back and gets logged in again the cart is empty. What is going on here?. Is this a normal behavior of woocommerce?. Do I have to do something else? maybe a plugin? Thanks. 回答1: I thought that the cart

Saving a product custom field and displaying it in cart page

我与影子孤独终老i 提交于 2019-11-27 15:24:35
With WooCommerce and I am doing some customization in my functions.php file, to get a custom field value on Cart page. I add a custom field before add to cart: function add_name_on_tshirt_field() { echo '<table class="variations" cellspacing="0"> <tbody> <tr> <td class="label"><label for="color">Name On T-Shirt</label></td> <td class="value"> <input type="text" name="name-on-tshirt" value="" /> </td> </tr> </tbody> </table>'; } add_action( 'woocommerce_before_add_to_cart_button', 'add_name_on_tshirt_field' ); function render_meta_on_cart_item( $title = null, $cart_item = null, $cart_item_key =

Prestashop: add customized product to cart

て烟熏妆下的殇ゞ 提交于 2019-11-27 15:24:12
问题 I'm writnig a custom controller for Prestashop. It is suposed to do a simple task: 1. Create a new cart if it wasn't created (working fine) 2. Get attribute ID from database (working fine) 3. Assign customization (one text field) 4. Add this product to cart. My current code: $idProduct = 1; // for me it's always one $qty= 1; // always add one item $text = (string)Tools::getValue('textField9'); // string of text customization $attribute = (int)Tools::getValue('sel_combination'); // atribute

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(

WooCommerce - Make a set of coupons adding a fixed fee to an order

浪子不回头ぞ 提交于 2019-11-27 08:42:27
问题 A client has a very odd request: they would like for a set of coupon codes to add a fee to an the order. Is this possible? The problem they are trying to solve is this: Currently the store offers free shipping to the lower 48 United States, for which I have shipping classes and table rates properly configured. However, the coupons the customer has sold on a daily deal site are supposed to remove the free shipping benefit and add a fixed shipping fee. How can achieve this? 回答1: Yes you can do

Remove add to cart button for specific product categories in WooCommerce 3

a 夏天 提交于 2019-11-27 08:21:23
问题 I need to hide the "add to cart" button for products of a defined product category. I would like the quantity fied still visible because I am using the Yith request a quote plugin which uses quantities for the quote system. The goal: hide "add to cart" button for a certain product category keeping the quantities fields. Im looking for a short string of code to place in my functions.php file. 回答1: Updated: (Added compatibility for WooCommerce Product Add-ons plugin in simple products) . Here

Change cart item prices based on custom cart item data in Woocommerce

给你一囗甜甜゛ 提交于 2019-11-27 08:06:29
问题 currently i create a form in product single page so that customer can enter height and width of the product . So the product price vary based on the entered height and width . I created this form in woocommerce->single-product->add-to-cart->simple.php Before modification the form is <form class="cart" method="post" enctype='multipart/form-data'> <?php /** * @since 2.1.0. */ do_action( 'woocommerce_before_add_to_cart_button' ); /** * @since 3.0.0. */ do_action( 'woocommerce_before_add_to_cart

Restricting cart items to be from the same product category in WooCommerce

拜拜、爱过 提交于 2019-11-27 07:59:51
问题 I am using the code below to remove other WooCommerce product category items from the cart when there is an item with a special product category 'cat_x' added in cart and display some different custom notices. The code came from this thread and just works well: add_action( 'woocommerce_check_cart_items', 'checking_cart_items' ); function checking_cart_items() { $special = false; $catx = 'cat_x'; $number_of_items = sizeof( WC()->cart->get_cart() ); if ( $number_of_items > 0 ) { // Loop through