cart

WooCommerce dynamic minimum order amount based fee

跟風遠走 提交于 2019-12-06 04:16:49
I need to set a minimum order fee in the shopping cart so if products in the cart don't total more than £10 then an extra fee is applied to bring the price up to £10. Here is the code I have at the moment which works well in the cart phase however when you reach the checkout the pricing section doesn't stop loading for some reason and you can't checkout, can anyone help? Code from functions.php: function woocommerce_custom_surcharge() { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $minimumprice = 10; $currentprice = $woocommerce->cart->cart_contents_total;

Tax class “Zero rate” per user role on specific product ID's

て烟熏妆下的殇ゞ 提交于 2019-12-06 04:11:39
I got this code that will apply tax free on a user role regardless of what they order, which is fine. But now I need another user role that will apply tax free on specific products id , and I'm not sure how to acomplish that. The code im using right now for tax free on all products for specific user role is: // Apply a different tax rate based on the user role. function wc_diff_rate_for_user( $tax_class, $product ) { // Getting the current user $current_user = wp_get_current_user(); $current_user_data = get_userdata($current_user->ID); if ( in_array( 'administrator', $current_user_data->roles

How to set a custom option of type “file” when adding a product to the cart in Magento?

点点圈 提交于 2019-12-06 03:28:05
问题 Using my own controller, I'm adding a product to the Magento cart. It has 3 custom options: 2 dropdown options (color and size) and a file option (design). The code adding the product to the cart is // obtain the shopping cart $cart = Mage::getSingleton('checkout/cart'); // load the product $product = Mage::getModel('catalog/product') ->load($productId); // do some magic to obtain the select ids for color and size ($selectedSize and $selectedColor) // ... // define the buy request params

WooCommerce: Cart price override with text

限于喜欢 提交于 2019-12-06 01:52:28
问题 We have a bunch of products with either: No price Zero price We made them purchasable with the built-in hook but the cart still displays them as having a 0 price during checkout. We'd like the cart & checkout summary to display "Special order" or any other text, but it seems WooCommerce invalidates text-based prices. Tried this : WooCommerce: Add product to cart with price override? The above works fine with a number override, but when tried with a text override it defaults back to displaying

Woocommerce: Display Product Variation Description on Cart page

二次信任 提交于 2019-12-06 01:29:48
问题 I'm trying to display my product variation description in my Cart. I have tried inserting this code in the cart.php template: if ( $_product->is_type( 'variation' ) ) {echo $_product->get_variation_description();} By following this documentation https://docs.woocommerce.com/document/template-structure/ But it's still not showing up. Not sure what I'm doing wrong here. Can anyone help on this? Thanks 回答1: UPDATE COMPATIBILITY for WooCommerce version 3+ Since WooCommerce 3, get_variation

Rails: Updating quantities in shopping cart

随声附和 提交于 2019-12-06 00:18:34
问题 Ruby newbie here. I'm going through Agile Web Development With Rails. In chapter 11 it challenges you to add a 'decrease quantity' button to items in the shopping cart. I went ahead and tried to implement an increase link as well. The problem is it's not doing anything when I click on the links. line_items_controller.rb def decrease @cart = current_cart @line_item = @cart.decrease(params[:id]) respond_to do |format| if @line_item.save format.html { redirect_to store_path, notice: 'Item was

WooCommerce: How to retain checkout info when client leaves then comes back?

混江龙づ霸主 提交于 2019-12-05 20:39:28
问题 Is there a simple way or a plugin to retain checkout information entered by the client after he/she leaves and comes back? This plugin retains "fields information for customers when they navigate back and forth" however it has quite a lot of recent bad reviews so I don't think I'll use that for production. Any alternative suggestion? 回答1: ---- Update ---- The code below is working, but only if data is submitted! The only possible ways are javascript/jQuery form event detection on checkout

Add a percentage discount based on customer total purchases sum in Woocommerce

不打扰是莪最后的温柔 提交于 2019-12-05 17:27:50
In Woocommerce, I would like to set a percentage discount based on customer total purchases sum. For example if the total purchase sum greater or equal to 200$ , customer get 5% discount . So, I have first part of code for showing the total sum: function get_customer_total_order() { $customer_orders = get_posts( array( 'numberposts' => - 1, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => array( 'shop_order' ), 'post_status' => array( 'wc-completed' ) ) ); $total = 0; foreach ( $customer_orders as $customer_order ) { $order = wc_get_order( $customer_order )

Magento: add product twice to cart, with different attributes!

点点圈 提交于 2019-12-05 17:13:48
I have been working with this for a whole day but i cannot find any solution: I have a product (lenses), which has identical attributes, but user can choose one attribute set for one eye and another attribute set for another. On the frontend I got it ok, see it here . So the user can select attributes for left or right eye, but it is the same product. I build a function, which should take a product in a cart (before save), add other set of attributes, so there should be two products in the cart. What happens is there are two products, but with the same set of attributes??? Here is the snippet

Dynamically calculate product price based on custom fields values when added-to-cart

微笑、不失礼 提交于 2019-12-05 15:24:01
I found the code to add existing product: global $woocommerce; $woocommerce->cart->add_to_cart(16); But I need to add product, with price that determined by 2 inputs: Age Quality I calculate the product's price by the formula age*quality. I know it's possible to add product with variations, but it's so many possible variations. Is it possible to set the product price dynamically based on custom fields calculation values? Thanks For the cart items (when product is added-to cart), is possible to set a custom dynamic calculated price based on product custom fields values. 1) First we add in the