cart

Minimum cart amount for specific product categories in WooCommerce

痞子三分冷 提交于 2021-02-01 05:13:34
问题 In WooCommerce I use an OUTLET category with on sale products and I would like to set a minimum subtotal (30 €) for customers purchasing any "Outlet" product. I tried to hook into woocommerce_after_calculate_totals to: check cart items for a specific product category display a notice when a specific product category is found and the order is lower than 30 € and eventually redirect to cart page when user tries to checkout with an order lower than 30 €. Here is my code: add_action( 'woocommerce

Change the default Shipping method in Woocommerce

安稳与你 提交于 2021-01-29 14:26:50
问题 I have two shipping methods. First is Free Shipping and second is Flat Rate Shipping for Express shipping for which i charge extra fee. By default Express Shipping is selected in the cart which lead to confusion among some buyers that I do not offer free shipping. Is it possible to change default selected method to free shipping? 回答1: I think that you just need to reorder your shipping methods for each shipping zone, moving "free shipping" on first line. If it doesn't work, you can add the

Allow shopify cart to checkout only if all cart items have same specific tag

房东的猫 提交于 2021-01-28 19:55:36
问题 Here’s my situation: I have products set up with 2 major collections/tags: day(example: monday-product) and location (example: location-vegas). All day tags have the same "-product" suffix and each location tag has the same "location-" prefix All products can be tagged with one day tag "monday-product" and one location tag “location-vegas”. If a person buys a product with the tags “location-vegas” and another product with the tag “location-la”, the checkout doesn’t work because it doesn’t

Limit to one applied coupon, removing other previous applied coupons in Woocommerce

白昼怎懂夜的黑 提交于 2021-01-28 11:48:50
问题 I am making coupon dynamically to use user email as coupon but how can I restrict user to use only one coupon per cart. If use multiple auto removed the previous one from cart. add_filter ( 'woocommerce_get_shop_coupon_data', 'generate_coupons', 10, 2 ); function generate_coupons( $data, $code) { global $wpdb, $woocommerce; $vpm_options = get_option( 'vpm_email_coupon_option_name' ); // Array of All Options $amount = $vpm_options['coupon_value_3']; // coupon_discount $offer_type = $vpm

Custom discount for every NTH item in the cart

て烟熏妆下的殇ゞ 提交于 2021-01-28 08:04:39
问题 I came here from this question here looking to find a solution for my WooCommerce site. I am looking for a way to get a discount in my cart only for even number of items in the cart. For example: If there's only 1 item in the cart: Full Price 2 Items in the cart: - (minus) 2$ for both of it 5 Items in the cart: - (minus) 2$ for 4 of it (if there's odd number of items in the cart. 1 item will always have the full price) By the way, all of my products are having the same price. Would someone be

Avoid error “call to a member function get_cart()…” in WooCommerce function

只愿长相守 提交于 2021-01-28 07:41:27
问题 Receiving an error on a code that did work previously but now it is stopping me editing a page in wordpress (As when I attempt to edit a page, it states there's been a critical error). The code below basically changes text for add to cart button depending if the related product is in the cart. Code below and error exception below that: function woocommerce_custom_add_to_cart_text($add_to_cart_text, $product ) { global $woocommerce; // Get cart $cart_items = $woocommerce->cart->get_cart();

Set a minimum quantity for cart items from specific WooCommerce product category

久未见 提交于 2021-01-28 05:10:47
问题 In WooCommerce, I am trying to set a minimum quantity for cart items from a specific product category. Based on "Minimum cart item quantity for a specific product category in WooCommerce", here is my code attempt : add_action( 'woocommerce_check_cart_items', 'wc_min_item_required_qty' ); function wc_min_item_required_qty() { $category = 'games'; // The targeted product category $min_item_qty = 4; // Minimum Qty required (for each item) $display_error = false; // Initializing // Loop through

Shipping methods only enabled in checkout page on Woocommerce

笑着哭i 提交于 2021-01-27 21:10:47
问题 On Woocommerce, we need to remove the shipping-methods from the Cart section an add it to the Checkout page only. Any track or help should be really appreciated? 回答1: There will be multiple ways to do it depending on the "why?" and on "for what?" you need this: 1) Hide shipping related from cart - The easiest way; add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_on_cart' ); add_filter( 'woocommerce_cart_needs_shipping', 'disable_shipping_on_cart' ); function disable

Replace the price of the cart item with a custom field value in Woocommerce

岁酱吖の 提交于 2021-01-27 18:08:26
问题 In WooCommerce I am trying to replace the price of the cart items inwith a custom field price. This is my code: function custom_cart_items_price ( $cart_object ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; foreach ( $cart_object->get_cart() as $cart_item ) { // get the product id (or the variation id) $id = $cart_item['data']->get_id(); // GET THE NEW PRICE (code to be replace by yours) $new_price = (int)get_post_meta( get_the_ID(), '_c_price_field', true ); // <== Add your code

WooCommerce cart quantity won't change after cart update

妖精的绣舞 提交于 2021-01-27 16:33:42
问题 I use the following snippet to change WooCommerce add to cart quantity rules. add_filter( 'woocommerce_quantity_input_args', 'custom_quantity_input_args', 10, 2 ); function custom_quantity_input_args( $args, $product ) { $custom_qty_product_ids = array(27345, 27346); if (!in_array($product->get_id(), $custom_qty_product_ids)) { $args['input_value'] = 25; $args['max_value'] = 500; $args['min_value'] = 25; $args['step'] = 25; } else { if (in_array($product->get_id(), $custom_qty_product_ids)){