Post by TraderDan » Sat Jan 14, 2012 2:10 am

What I want to do is pretty simple in theory, but I have had no luck so far achieving this. Any help is greatly appreciated...

Rather than use the 'requires shipping' feature associated with each product, I really need opencart to display the shipping/delivery modules from the Shopping Cart and Checkout if and only if the total cart weight is greater than zero. Can somebody please help me?

So far, all attempts at using weight-based shipping modules has fallen short because even though the shipping charge might evaluate to $0.00 for a cart weight of 0.00, the idea here is to be able to completely skip over the shipping requirements during checkout if the cart weight is truly zero. Make sense? Thanks in advance...
Last edited by TraderDan on Sat Jan 14, 2012 5:00 am, edited 1 time in total.

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by TraderDan » Sat Jan 14, 2012 2:30 am

To put it one other way, here is an example of the problem I'm facing...

THE GIVENS:
- I have a product with 'Requires Shipping' set to no, a base weight of 0.00, and a set of options associated with it.
- A couple of the product options have individual weight values > 0.00 while a couple others have weight individual weight values that = 0.00 (these are digital download options).

THE PROBLEMS:
- If a customer chooses one of the options that has weight > 0, they are skipped over the shipping options during checkout.
- And if I change the 'Requires Shipping' option to yes for that product, then even if a customer chooses one of the digital options (weight = 0.00), they still get shown all the shipping steps during checkout.

I need the shipping module to trigger automatically, based solely on the total weight of the cart, nothing else.
Can this be done without pulling all my hair out? Again, thanks...

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by OpenCart Addons » Sat Jan 14, 2012 4:23 am

Have you thought about changing the "Free Shipping" to read "No Shipping", and set it available if cart weight is 0?

In catalog / language / english / shipping / free.php
Find:

Code: Select all

$_['text_title']       = 'Free Shipping';
$_['text_description'] = 'Free Shipping';
Replace With:

Code: Select all

$_['text_title']       = 'Digital Download';
$_['text_description'] = 'Digital Download';
In catalog / model / shipping / free.php
Find:

Code: Select all

$method_data = array();
Before Add:

Code: Select all

if ($this->cart->getWeight() > 0) {
			$status = false;
		}

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by TraderDan » Sat Jan 14, 2012 4:34 am

Thank you so much for this suggestion, it definitely gets the job done as far as workarounds go.

Still though, I'd be willing to pay for a custom modification that allows a customer to completely skip over all the shipping steps during checkout if the total cart weight is equal to zero. Any takers?

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by OpenCart Addons » Sat Jan 14, 2012 4:46 am

You could also modify your system file where it checks for shipping.

In system / library / cart.php
Find:

Code: Select all

public function hasShipping() {
		$shipping = false;
		
		foreach ($this->getProducts() as $product) {
	  		if ($product['shipping']) {
	    		$shipping = true;
				
				break;
	  		}		
		}
		
		return $shipping;
	}
Replace With:

Code: Select all

public function hasShipping() {
		$shipping = false;
		
		foreach ($this->getProducts() as $product) {
	  		if ($product['shipping']) {
	    		$shipping = true;
				
				break;
	  		}		
		}

		if ($this->getWeight() <= 0) {
			$shipping = false;
		}

		return $shipping;
	}

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by TraderDan » Sat Jan 14, 2012 4:56 am

YES! YES! YES! YES! YES! YES! YES! YES! YES! YES! YES! YES! YES!

THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!

This is EXACTLY what I was trying to do, I knew it had to be a simple thing! (I'm just not much of a programmer, and opencart is still very new to me)


One last request:

How can I make it so that my Handling Fee is only applied if the cart weight is greater than zero? Right now my $2.00 Handling Fee is being applied to all products, but I only want to include it when shipping physical items.

Thanks again, you've already helped me out SO MUCH!!

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by OpenCart Addons » Sat Jan 14, 2012 4:59 am

Not a problem, glad to help.

For the handling fee, edit the file
catalog / model / total / handling.php
Find:

Code: Select all

if (($this->cart->getSubTotal() < $this->config->get('handling_total')) && ($this->cart->getSubTotal() > 0)) {
Replace With:

Code: Select all

if (($this->cart->getSubTotal() < $this->config->get('handling_total')) && ($this->cart->getSubTotal() > 0) && ($this->cart->getWeight() > 0)) {
**Edit:
Attached a vQmod that will apply these changes for you so you won't have to modify your core files.


Cheers,
Joel.

Attachments

OpenCart v1.5.1.3

Last edited by OpenCart Addons on Sat Jan 14, 2012 5:10 am, edited 1 time in total.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by TraderDan » Sat Jan 14, 2012 5:10 am

Joel, you solved all my shipping problems... you are officially my hero, I can't thank you enough!

Would it be wise on my part to incorporate these modifications into a vqmod as opposed to performing the changes on core files? In theory, these core files will get overwritten next time opencart gets upgraded to a new release, correct?

Thanks again for all your help.

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by OpenCart Addons » Sat Jan 14, 2012 5:13 am

See my previous post, already one step ahead of you. :)

Cheers,
Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by TraderDan » Sat Jan 14, 2012 5:16 am

Oh man, you really ARE my hero. If you're ever in the greater Boston area, I'm buying you dinner!

Thanks again, -Dan

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by pgp » Mon Jan 30, 2012 1:20 pm

Hi,

I have a similar issue. Right now I want weight based shipping to be applied to only if item is more than 25kgs. Is this possible?

For an example, I have 2 items called A and B. Item A weight only 10kgs. But Item B weight 25kgs. So if a customer is checking out with item A, then cart shouldn't display weight based shipping as an option but other shipping methods are used. But if a customer is checking out with item B then I want weight based shipping displayed as per shipping method. is this possible to achieve?

Thank you in advance,
pgp

pgp
New member

Posts

Joined
Mon Jan 30, 2012 1:08 pm

Post by OpenCart Addons » Tue Jan 31, 2012 12:55 am

Hey,

This is possible.

in catalog / model / shipping / weight.php
Find:

Code: Select all

if ($status) {
Add Before:

Code: Select all

if ($this->cart->getWeight() < 25) {
$status = false;
}
This feature is already integrated into my commercially available Improved Weight Based Shipping extension here:
http://www.opencart.com/index.php?route ... on_id=3335

Regards,
Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by pgp » Tue Jan 31, 2012 4:08 am

Joel,

Thank you so much :). You are a life saver.

regards,
pgp

pgp
New member

Posts

Joined
Mon Jan 30, 2012 1:08 pm

Post by budalal » Tue Jun 19, 2012 12:15 am

Hi,

Great thread. What would need to be done to restrict shipping if any item's weight is set to 0. I have lots of products with no weight info and would like to restrict shipping to people outside my area. Would like to add a message saying one or more items is not eligible for shipping to your country, zone, etc.

Thanks in advance.

OC 1.5.1.3

New member

Posts

Joined
Sun Oct 24, 2010 2:05 pm

Post by Leksmaster » Tue Jul 24, 2012 3:50 pm

Hello Guy

Please can someone help me here. Basically am using Royal Mail shipping weight. have set all the weight and price.

What i want now is i don't want to display Royal Mail First Class Standard and Royal Mail Second Class Standard if total amount is ABOVE £5, then display order shipping option like First class Recorded etc... So if the Total amount is below £5 i want to display all the shipping Method

Example
Royal Mail First Class Standard
Royal Mail Second Class Standard
Royal Mail Special Delivery 1PM
Royal Mail First Class (Recorded)
ParcelForce 24
*Display All if total amount is less that £5

Royal Mail Special Delivery 1PM
Royal Mail First Class (Recorded)
ParcelForce 24
*Display All if total amount is More Than that £5.

Note: Am going to set all the weight=price to each shipping method in the Royal Mail Based in the admin. if any weight product is less or greater that's when the above details trigger.

Thanks in advance. Regards

Newbie

Posts

Joined
Fri Jun 15, 2012 4:37 pm

Post by ozgirl57 » Tue Aug 28, 2012 11:13 pm

Brilliant!
Thank you for this mod :-*

Newbie

Posts

Joined
Sat Jun 12, 2010 2:02 am

Post by OpenCart Addons » Fri Sep 14, 2012 5:33 am

budalal wrote:Hi,

Great thread. What would need to be done to restrict shipping if any item's weight is set to 0. I have lots of products with no weight info and would like to restrict shipping to people outside my area. Would like to add a message saying one or more items is not eligible for shipping to your country, zone, etc.

Thanks in advance.

OC 1.5.1.3
In catalog / model / shipping / free.php
Find:

Code: Select all

$method_data = array();
Before Add:

Code: Select all

if ($this->config->get('config_weight_class_id')) {
$weight_class = 'weight_class_id';
} else {
$weight_class = 'weight_class';
}
	
foreach ($this->cart->getProducts() as $product) {
if ($this->weight->convert($product['weight'], $product[$weight_class], $this->config->get('config_' . $weight_class)) <= 0) {
$status = false;
}
}

Leksmaster wrote:Hello Guy

Please can someone help me here. Basically am using Royal Mail shipping weight. have set all the weight and price.

What i want now is i don't want to display Royal Mail First Class Standard and Royal Mail Second Class Standard if total amount is ABOVE £5, then display order shipping option like First class Recorded etc... So if the Total amount is below £5 i want to display all the shipping Method

Example
Royal Mail First Class Standard
Royal Mail Second Class Standard
Royal Mail Special Delivery 1PM
Royal Mail First Class (Recorded)
ParcelForce 24
*Display All if total amount is less that £5

Royal Mail Special Delivery 1PM
Royal Mail First Class (Recorded)
ParcelForce 24
*Display All if total amount is More Than that £5.

Note: Am going to set all the weight=price to each shipping method in the Royal Mail Based in the admin. if any weight product is less or greater that's when the above details trigger.

Thanks in advance. Regards
I'm going to make the assumption that your currency is already set to £. I'm also going to use the SubTotal to check the status of the shipping.

Find:

Code: Select all

if ($this->config->get('royal_mail_1st_class_standard_status') && $address['iso_code_2'] == 'GB') {
Replace With:

Code: Select all

if ($this->config->get('royal_mail_1st_class_standard_status') && $address['iso_code_2'] == 'GB' && $this->cart->getSubTotal() < 5) {
Find:

Code: Select all

if ($this->config->get('royal_mail_2nd_class_standard_status') && $address['iso_code_2'] == 'GB') {
Replace With:

Code: Select all

if ($this->config->get('royal_mail_2nd_class_standard_status') && $address['iso_code_2'] == 'GB' && $this->cart->getSubTotal() < 5) {
etc.... I think you could figure it out from here.


Regards,
Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by zohf » Wed May 01, 2013 11:07 am

Having a similar issue.

I have successfully set this up:

If my cart weight = 0, then I only display the free-shipping module. If my cart weight is greater than or equal to 0, then I use the UPS module.

Here is my issue. If I have a item of '0' weight (or a free-shipping item) in the cart along with any other item of weight (or an item that has a shipping cost), UPS assumes that the '0' weight item is the base rate, and charges as such.

Is there a way to implement a rule that say:

If my item is set to weight '0', then associate no shipping cost? Or maybe I could say 'if my item is set to weight '0', then mark the item as 'does not require shipping', but only if there are other items in the cart of weight?

I am half way there on figuring this out. Any help is greatly appreciated.

Thanks.

Newbie

Posts

Joined
Thu Apr 25, 2013 3:17 am
Who is online

Users browsing this forum: No registered users and 13 guests