shipping

Set a percentage discount to Local pickup shipping method in Woocommerce

丶灬走出姿态 提交于 2020-08-04 19:20:06
问题 I have a WordPress site which uses WooCommerce plugin. I would like to offer buyer 5% reduction from cart total if they select local pickup as a shipping method. I already tried - 5 * [qty] and it doesn't seem to be working. I also tried -0.95 * [cost] with no luck 回答1: I am using WooCommerce 3 and achieved the above result by writing a function inside the function.php of active theme. function prefix_add_discount_line( $cart ) { $chosen_methods = WC()->session->get( 'chosen_shipping_methods'

How to add Custom Description field in Shipping methods (Backend)

南楼画角 提交于 2020-08-03 14:07:15
问题 I want to add a custom field in Shipping Zone page under shipping method, it will be a text input, the user will able to add a custom message and I'll show that message in the front end. I noticed it saves the data in wp_woocommerce_shipping_zone_methods table which doesn't have any extra column to save the data; so I think I have to use my custom logic, but I don't know the name of the hook(s). So my question is, is there is any hook which will help/allow me To add a custom field. To add a

How to add Custom Description field in Shipping methods (Backend)

允我心安 提交于 2020-08-03 14:05:15
问题 I want to add a custom field in Shipping Zone page under shipping method, it will be a text input, the user will able to add a custom message and I'll show that message in the front end. I noticed it saves the data in wp_woocommerce_shipping_zone_methods table which doesn't have any extra column to save the data; so I think I have to use my custom logic, but I don't know the name of the hook(s). So my question is, is there is any hook which will help/allow me To add a custom field. To add a

Custom display based on Woocommerce product variations stock data checkbox option

丶灬走出姿态 提交于 2020-07-22 06:12:22
问题 I am trying to add a custom message to variation products, based on their stock quantity and stock status. So far i got this: function load_variation_settings_fields( $variation_data, $product, $variation ) { // Display shipping delay text when stock quantity exist if( $variation->get_stock_quantity() > 0 ) $variation_data['text_field'] = __('<p class="stock in-stock">Stock: <span>På lager</span><br>Delivery: <span>2-12 hverdage</span></p>'); else $variation_data['text_field'] = __('<p class=

Add update or remove WooCommerce shipping order items

雨燕双飞 提交于 2020-07-14 09:17:57
问题 I have added shipping cost for the orders that are synced from amazon. For some reason I had to set custom shipping flat price in woo-orders created for amazon-order. It is done as follow: $OrderOBJ = wc_get_order(2343); $item = new WC_Order_Item_Shipping(); $new_ship_price = 10; $shippingItem = $OrderOBJ->get_items('shipping'); $item->set_method_title( "Amazon shipping rate" ); $item->set_method_id( "amazon_flat_rate:17" ); $item->set_total( $new_ship_price ); $OrderOBJ->update_item( $item )

Hide shipping methods based on products categories in Woocommerce

人走茶凉 提交于 2020-06-26 14:13:52
问题 With Woocommerce, I would like to hide all shipping methods except "Local pickup" when a defined products category is in cart… The code below does that for other product types, except variable products: add_filter( 'woocommerce_package_rates', 'custom_shipping_methods', 100, 2 ); function custom_shipping_methods( $rates, $package ){ // Define/replace here your correct category slug (!) $cat_slug = 'my_category_slug'; $prod_cat = false; // Going through each item in cart to see if there is

Magento Hide other shipping methods if shipping price is 0.00 without module

守給你的承諾、 提交于 2020-02-07 13:16:28
问题 I am trying to hide other shipping methods if the shipping price is 0.00 without using or creating a custom module. The desired algorithm is: If shipping price is 0.00 hide all other shipping methods This is the Abstract.php I've tried: <?php public function getShippingRates() { $groups = parent::getShippingRates(); $free = array(); foreach($groups as $code => $_rates) { foreach($_rates as $_rate) { if (!$_rate->getPrice() > 0) { $free[$code] = $_rates; } } } if (!empty($free)) { return $this

Magento Hide other shipping methods if shipping price is 0.00 without module

坚强是说给别人听的谎言 提交于 2020-02-07 13:13:41
问题 I am trying to hide other shipping methods if the shipping price is 0.00 without using or creating a custom module. The desired algorithm is: If shipping price is 0.00 hide all other shipping methods This is the Abstract.php I've tried: <?php public function getShippingRates() { $groups = parent::getShippingRates(); $free = array(); foreach($groups as $code => $_rates) { foreach($_rates as $_rate) { if (!$_rate->getPrice() > 0) { $free[$code] = $_rates; } } } if (!empty($free)) { return $this

Woocommerce - Create Free shipping for single item while using UPS extension

南楼画角 提交于 2020-01-25 00:43:28
问题 I am using the UPS extension in woocommerce. I need to offer free shipping on some items, bypassing the UPS calculator. It seems one good way to do this is to mark the item as "virtuaL," but then the item doesn't require shipping. I need to require shipping for this item. I have been able to customize the checkout page and force the shipping fields to show on the virtual items, but then they don't store in the actual orders. Anybody know how I can create a custom function or modify the

Shipping costs and restrictions based on location and product category in WooCommerce

霸气de小男生 提交于 2020-01-24 21:54:27
问题 I'm using Woocommerce and I'd like to restrict the shipping class 'alcoholics' and allow it just for just Italy and no other countries, can you help me with this code? Thank you very much for your help! function( $is_available ) { $cart_items = WC()->cart->get_cart(); foreach ( $cart_items as $cart_item ) { $product = $cart_item['data']; $class = $product->get_shipping_class(); if ( $class === 'alcoholics' ) { return false; } } return $is_available; } add_filter( 'woocommerce_states', 'AL