Without coupon = Shipping free, with coupon = with shipping - WooCommerce - php

I need help for my WooCommerce Shop.
Our customers get free shipping after a amount of 39€.
If our customers get a price under 39€ after using a coupon, shipping is no more free.
So for example:
Customers is on Cart, full cart amount is 42€ = Shipping Free.
Use -15% off Coupon = cart amount is 38,55 = Shipping costs <- but this still have to be free
In the plugin i use, i can set the setting "allow shipping free" but then the customer gets shipping free after the minimum amount for the coupon so this isnt usefull for us.
I use the Plugin = WooCommerce Extended Coupon Features FREE
https://de.wordpress.org/plugins/woocommerce-auto-added-coupons/
Hope you guys understand what I mean

You can achieve this by using a simple code snippet.
you need to config one Free shipping without any Minimum order amount and a Flat rate to display normal shipping.
Now copy and paste below snippet into functions.php. It will hide free shipping if the subtotal less than 39, otherwise hide flat rate
add_filter( 'woocommerce_package_rates', 'modify_shipping_rate', 15, 2 );
function modify_shipping_rate( $available_shipping_methods, $package ){
global $woocmmerce;
$total_coast = WC()->cart->get_subtotal();
if( $total_coast < 39 ){
unset($available_shipping_methods['free_shipping:4']); // Config the Free Shipping method id properly
}else{
unset($available_shipping_methods['flat_rate:1']); //// Config the Flatrate shipping method id properly
}
return $available_shipping_methods;
}

Related

Change final shipping rate based on the product weight in magento

I am using table rate for shipping methods configuration.
But the final shipping rate will change based on the product weight.
Final shipping rate=Shipping rate*Product weight
For Ex: If the prdouct weight=6kg,Final shipping rate will be 6*100
if the prdouct weight=11kg,Final shipping rate will be 11*90.
How can i achieve this feature?
Please do a modification on this file
app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php
change line 166 from,
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
to
$shippingPrice = ($rate['price']*$request->getPackageWeight());

wooCommerce shipping quantity issue

I have an e-commerce website based on wooCommerce. I have some shipping restrictions with the Shipping Company.
I can only ship 6/12/18 products. For shipping currently I am using Table Rate Shipping plugin in which I have set free shipping for zone and for 6/12/18 products. With this I am using Minimum Purchase Rule for minimum 6 quantity for the cart.
But customers can add 7/8 products and shipping method is allowing it (as the minimum cart limit is 6) which should not be allowed.
So is there any way we can restrict quantity in between 6-12-18?
One more thing, when I enter straight 7/8 products it gives me shipping error as this quantity is not allowed but when I enter combination of products like 6+1/5+3 it is allowing it.
Thank you!

Wordpress - How to make shipping price zero in woocommerce?

I have a condition where I want to make shipping price zero. Is there any predefined function for that? like we have a predefined function for making the cart empty,
$woocommerce->cart->empty_cart();
Similarly is there any function to make shipping price zero?
As per the official documentation:
If free shipping is enabled customers will have access to free shipping on their orders. You can however specify a few conditions they must meet to be granted free shipping such as;
Minimum order amount
Coupon (Users will need to enter a valid free shipping coupon code to use this method. If a coupon is used, the minimum order amount will be ignored)
You can also choose specific countries to which free shipping is allowed.
Further, the free shipping method has an is_available function which can be hooked into:
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available );
This means you can use add_filter() on woocommerce_shipping_free_shipping_is_available and return true or false.

How to get all available shipping methods programmatically in magento?

I'm using magento C.E 1.7. I use all shipping methods of magento and I'm viewing only one shipping method in the front end, which has higher priority. I'm using table rate shipping for some countries.
I wanted to add special fixed shipping price for some products when they shipped to that countries only. So that, I added new shipping method namely 'flat rate per product', by using a new module.
Based on this module, a text box is added to all the products in admin to specify the special shipping price. If I filled this field with some value, It considers it as a special shipping price. And if not filled it, it will be considered as special shipping price is $0.
So I have given least priority in the sort order for this shipping method to avoid this method from viewing on front end when products without special shipping price and products with special shipping price both are added into the cart.
So that, If only the special shipping priced product is added to the cart, It shows only table rate shipping method in front end.
I checked the code in availble.phtml. There is a foreach loop to proceed with available shipping methods. I need to check the availability of the 'flat rate per product' and it's price value for the product before start of loop execution.
I tried to get all the values of the array. But I could not. Can anyone help on this?
you can use this code:
<?php
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
$shipMethods = array();
foreach ($methods as $shippigCode=>$shippingModel)
{
$shippingTitle = Mage::getStoreConfig('carriers/'.$shippigCode.'/title');
$shipMethods[$shippigCode] = $shippingTitle;
}
return $shipMethods;
?>

Prestashop shipping cost modification

I need Prestashop to calculate shipping price depend on items quantity in cart.
If there is more than one item in cart, i want the shipping price to be 50% of sum of all shipping costs.
I modyfied the cart module, but when i proceed to order page, the shipping cost is still full amount.
My code in blockcart:
if($nbTotalProducts>1) {
$shipping_cost_float = $shipping_cost_float/2;
$shipping_cost = $shipping_cost/2;
}
How can i store new shipping cost for all modules/controllers?
I think, i found the solution.
I have modified the cart class (classes/cart.php) - getPackageShippingCost function.
I add this code before the shipping cost is converting to float:
$product_array = $this->getProducts();
$pcount = 0; //quantity of products in cart
$moreThanOneQuantity = FALSE;
foreach($product_array as $product_item) {
$pcount++;
if($product_item['quantity']>1) $moreThanOneQuantity = TRUE;
}
if($shipping_cost>0 && ($pcount>1 || $moreThanOneQuantity )) $shipping_cost=$shipping_cost/2;
Hope it will help someone.
This is not that simple to manipulate shipping cost. They depends on the carrier used for the cart. I think you should try to set fixed value in the carrier option, and define many price range.
If it's not enough, the best solution for me is to use a new cartrule. Create one that give free shipping, and override CartRule class. In the method getContextualValue, the shipping cost is setted to 0 here. i think you may change it to remove 50% instead. You may have to change some template rendering too (your cart will display a free shipping).
Hope it help.
I dont think you need to code here. You can try to play with the weights of the productos.
For example, you put all your items with weight 1 and you configure your shipping cost to be 50% more if the weight is up to 1. This way you will have what you want if I understood correctly

Categories