Post by KDNovelties » Wed Nov 22, 2017 12:26 am

Hi everyone. Is there an option for to set free shipping based on total not subtotal. When someone uses a coupon, it drops their total below the free shipping amount, but they still get free shipping, which is not what is needed. What I've done so far, but has not worked is change getSubTotal to getTotal in catalog/model/extension/shipping/free.php

Any help would be greatly appreciated.

User avatar
New member

Posts

Joined
Sat May 27, 2017 12:12 am

Post by thekrotek » Wed Nov 22, 2017 3:26 am

Well, total is a sum of ALL order totals, including shipping. I'm not sure, how you can base shipping on total, when total INCLUDES shipping costs.

Professional OpenCart extensions, support and custom work.
Contact me via email support@thekrotek.com


User avatar
Active Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by KDNovelties » Wed Nov 22, 2017 4:50 am

So what would be the recommendation? See details below

$65 Free Shipping

$70 Subtotal
$10 Coupon
Customer is still getting free shipping.
That new total is $60, so free shipping should not apply.

Thanks
Angel

User avatar
New member

Posts

Joined
Sat May 27, 2017 12:12 am

Post by thekrotek » Wed Nov 22, 2017 5:12 am

Put Shipping order total BELOW the Coupon and see, how it works.

Professional OpenCart extensions, support and custom work.
Contact me via email support@thekrotek.com


User avatar
Active Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by KDNovelties » Wed Nov 22, 2017 7:39 am

Thanks, shipping order total was already below the coupon. I changed it to be on top and same thing. From what I understand, that only changes the sort order. Not any calculations. There should be a way of doing this.

User avatar
New member

Posts

Joined
Sat May 27, 2017 12:12 am

Post by KDNovelties » Wed Nov 22, 2017 8:27 am

So I was able to put this together, however, it only works if the page is refreshed... Any help appreciated. Thanks

Code: Select all

	<file name="catalog/model/extension/total/coupon.php">
		<operation>
			<search position="before"><![CDATA[$total['total'] -= $discount_total;]]></search>
			<add><![CDATA[$this->session->data['coupon_discount'] = $discount_total;]]></add>
		</operation>		
	</file>

	<file name="catalog/model/extension/shipping/free.php">
		<operation>
			<search position="before"><![CDATA[$method_data = array();]]></search>
			<add><![CDATA[        if ( (isset($this->session->data['coupon']) && ($this->session->data['coupon'] != '')) &&
             (isset($this->session->data['coupon_discount']) && ($this->session->data['coupon_discount'] != '')) ) {

             $coupon_discount = $this->session->data['coupon_discount'];

             if ($this->cart->getSubTotal() < ($this->config->get('free_total') + $coupon_discount)) {
                 $status = false;
             }
        }]]>
			</add>
		</operation>		
	</file>

User avatar
New member

Posts

Joined
Sat May 27, 2017 12:12 am

Post by thekrotek » Wed Nov 22, 2017 4:21 pm

KDNovelties wrote:
Wed Nov 22, 2017 7:39 am
Thanks, shipping order total was already below the coupon. I changed it to be on top and same thing. From what I understand, that only changes the sort order. Not any calculations. There should be a way of doing this.
You understand wrong. Most totals calculated differently depending on their position in the list. But not all of them: coupons, for example, always calculated from subtotal.

Professional OpenCart extensions, support and custom work.
Contact me via email support@thekrotek.com


User avatar
Active Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Johnathan » Wed Nov 22, 2017 11:13 pm

You don't need to change the coupon Order Total, what you need is a shipping method that can base its calculation on the full total at the point of the "Shipping" line item. Total-Based Shipping can do this, so that you can use the sub-total + coupon + other line items that come before "Shipping". For example:

------------------------------------------------------------------------------
CHARGE #1
Title: Free Shipping Over $100
Sort Order: 1
Charge Field: 100-99999 = 0
Rule: Total Value = Total
------------------------------------------------------------------------------

Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any further questions.

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 75 guests