Post by clubplug » Thu Oct 21, 2021 2:00 am

Hi Folks
Not sure if this was ever brought up, tried looking for it on forum but found nothing.
Here is an example. Let us say we have Free Shipping on all orders over $99. Is there a way so that let's say the customer adds products to cart that add up to only for $80. When they go to View Cart and do a Estimate Shipping cost and the window pops up with the shipping cost, can is also have a message in that box saying, example... "Only $19.01 to qualify for Free Shipping"

I hope I explained this correctly...
Thank you.

New member

Posts

Joined
Sun Dec 22, 2019 12:42 am

Post by paulfeakins » Thu Oct 21, 2021 5:43 pm

If you can't find an extension, you could pay a developer such as ourselves or post a job in the Commercial Support Forum.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by straightlight » Thu Oct 21, 2021 10:52 pm

Hi clubplug,

While this idea might be an interesting one, in order to develop this kind of information to guests / customers, a discounted field to the payment service provider must also be involved; not only from the store in order for the shipping service provider to consider the reduced price of delivery, once 99.01 and above are counted, with the serviceability quotes. There are shipping service providers requiring the payment's transaction ID (especially in the American continent) and checking the load balancing as well as the quality of the products during service.

The question would, then, become the knowing of the payment service provider you'd be using in order to achieve this request.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Johnathan » Fri Oct 22, 2021 2:29 am

Formula-Based Shipping can do this. It has "Text" type charges that are just informational messages, and you can use formulas in them to display a particular value based on the cart total. In your case you'd do this:

------------------------------------------------------------------------------
CHARGE #1
Title: Free shipping informational message
Group: A
Charge Type: Text (Warning)
Charge Field: You only ${99.01 - [total] to qualify for Free Shipping!
Rule: Total of cart = 0-99.01
------------------------------------------------------------------------------

You can also set up the Free Shipping rate itself in that extension, though you don't have to. 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 questions.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by clubplug » Fri Oct 22, 2021 2:57 am

Thank you Johnathan. Great help!!

New member

Posts

Joined
Sun Dec 22, 2019 12:42 am

Post by thekrotek » Fri Oct 22, 2021 3:33 am

All you need is a simple modification, which will add an alert with the given data. This, of course, is valid if you don't have lots of shipping/payment extensions and only need to display a notification for the particular one.

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


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by straightlight » Fri Oct 22, 2021 8:14 pm

One way I could see this could work is by putting the word 'shipping' in the total_ variables where shipping estimations do apply. This way, during checkout, both service availability estimation vs. the store owner's estimated price could be informed to customers from an event showing in the payment method step as long as the shipping from the total would appear in the discounted field of the payment service provider. Otherwise, if no shipping quote nor discounted field can be used, then the customer would still need to cover the cost on anyhow.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by by mona » Sun Oct 24, 2021 2:39 am

You would basically only need to create a OC or VQ modification which changes 3 files, 1 php, 1 twig and 1 language file:

file 1: catalog/controller/extension/total/shipping.php function quote

after this:

Code: Select all

	if ($this->session->data['shipping_methods']) {
		$json['shipping_method'] = $this->session->data['shipping_methods'];
	} else {
		$json['error']['warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact'));
	}

add:

Code: Select all

	// show gap between cart sub total and global free shipping amount when the gap is half of the total on the shipping estimates popover window
	// global free shipping, shipping_free_geo_zone_id equals zero
	$freestatus = (!$this->config->get('shipping_free_geo_zone_id') ? true : false);
	if ($freestatus) {
		$threshold = $this->config->get('shipping_free_total');
		$grand_total = $this->cart->getSubTotal();
		if ($grand_total >= $threshold) {
			$json['msgfreeshipping'] = '';
			$json['slider_free_shipping'] = '';
		} else {
			$gap = $threshold - $grand_total;
			$freeshipping_gap = $this->currency->format($gap, $this->session->data['currency']);
			// display only if the gap is half the threshold or the amount towards free shipping is rather big.
			if ($gap <= $threshold/2) {
		$json['msgfreeshipping'] = '<div style="text-align:center;"><i class="fas fa-truck" data-toggle="tooltip" title="Free Shipping"></i>You are only <strong><span>'.$freeshipping_gap.'</span></strong> away from <strong>FREE&nbsp;Shipping</strong> on this order.</div>';
		$json['slider_free_shipping'] = '<div><span style="float:left">'.$this->currency->format(1, $this->session->data['currency']).'</span><span style="float:right">'.$this->currency->format($threshold, $this->session->data['currency']).'</span></div><div><input disabled type="range" min="1" max="'.$threshold.'" value="'.$grand_total.'"></div>';
			}
		}
	}
OR something like this which enables the free shipping message when set for a specific geo zone.

Code: Select all

	// is free shipping extension enabled
	if ($this->config->get('shipping_free_status')) {
		// free shipping for all geo zones
		$free_zone_global = (!$this->config->get('shipping_free_geo_zone_id') ? true : false);
		if (!$free_zone_global) {
			// free shipping for specific geo zone, does this zone belong to that geo zone?
			$free_zone = false;
			$sql = "SELECT zone_to_geo_zone_id 
			FROM oc_zone_to_geo_zone
			WHERE geo_zone_id = ".(int)$this->config->get('shipping_free_geo_zone_id')."
			AND country_id = ".(int)$this->request->post['country_id']."
			AND (zone_id = ".(int)$this->request->post['zone_id']." OR zone_id = 0)";
			$result = $this->db->query($sql);
			if ($result->num_rows) $free_zone = true;
		}
		// free shipping for all or zone belongs to specific free shipping geo zone
		if ($free_zone_global || $free_zone) {
		$threshold = $this->config->get('shipping_free_total');
		$grand_total = $this->cart->getSubTotal();
		if ($grand_total >= $threshold) {
			$json['msgfreeshipping'] = '';
			$json['slider_free_shipping'] = '';
		} else {
			$gap = $threshold - $grand_total;
			$freeshipping_gap = $this->currency->format($gap, $this->session->data['currency']);
			// display only if the gap is half the threshold or the amount towards free shipping is rather big.
			if ($gap <= $threshold/2) {
		$json['msgfreeshipping'] = '<div style="text-align:center;"><i class="fas fa-truck" data-toggle="tooltip" title="Free Shipping"></i>You are only <strong><span>'.$freeshipping_gap.'</span></strong> away from <strong>FREE&nbsp;Shipping</strong> on this order.</div>';
		$json['slider_free_shipping'] = '<div><span style="float:left">'.$this->currency->format(1, $this->session->data['currency']).'</span><span style="float:right">'.$this->currency->format($threshold, $this->session->data['currency']).'</span></div><div><input disabled type="range" min="1" max="'.$threshold.'" value="'.$grand_total.'"></div>';
			}
		}
	}


The html in the messages you can best put in your language files and then use sprintf with the variables, better not put html in your php code.
This only works for global free shipping, if your free shipping is based on a specific geo zone, you need to find the zeo zone which the shipping address belongs to and compare that with the config value but you get the idea as to where these things have to go.

for the display part, message and slider:

file 2: catalog/view/theme/default/template/extension/total/shipping.twig function $('#button-quote').on('click', function()

before:

Code: Select all

		for (i in json['shipping_method']) {
you add:

Code: Select all

		if (json['msgfreeshipping']) {
			html += json['msgfreeshipping'];
		}
		if (json['slider_free_shipping']) {
			html += json['slider_free_shipping'];
		}



file 3: catalog/view/theme/default/template/extension/total/shipping.php

here you can put the language dependent html with the %s parameters.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by straightlight » Sun Oct 24, 2021 3:21 am

Perhaps you are referring to the model instead of a controller? The core does not have the getQuote method in the controller out-of-the-box. In addition, these should be suggested to be used as an event trigger: https://github.com/opencart/opencart/wiki/Events-System . Furthermore, these modifications suggests the adjustment as merchant-based as opposed to discounted values.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by by mona » Sun Oct 24, 2021 3:42 am

I am sure Jonathan’s ready made module works as described for those without the time or skills to use the concept.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 264 guests