Post by wafflemeister » Sat Jan 18, 2025 3:55 am

I run Opencart 1.5.6.4. I would like to modify the weight based shipping module. The modification should check the cart content for product ID and if let's say if product ID 0001 is in the cart I would like it to not show any of the weight based shipping options. Thank you in advance for your help!

Active Member

Posts

Joined
Fri Jun 21, 2013 11:10 pm

Post by johnp » Sat Jan 18, 2025 7:04 am

You might be better off getting an extension for that rather then reinvent the wheel.

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD lover, user and geek.
Affordable Service £££ - Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
FREE Guidance and Advice at https://www.ecommerce-help.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by Cue4cheap » Sat Jan 18, 2025 10:22 pm

wafflemeister wrote:
Sat Jan 18, 2025 3:55 am
I run Opencart 1.5.6.4. I would like to modify the weight based shipping module. The modification should check the cart content for product ID and if let's say if product ID 0001 is in the cart I would like it to not show any of the weight based shipping options. Thank you in advance for your help!
How about by model?
in catalog/model/extension/shipping/weight.php

Code: Select all

$os = array("MODEL1", "MODEL2");
if (in_array($product['model'], $os)) {
$status = false;
}
Place before
if ($status) {

Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by Johnathan » Sat Jan 18, 2025 11:20 pm

If you don't want to have to modify code yourself, my Category & Product-Based Shipping (https://www.getclearthinking.com/catego ... d-shipping) extension can do this. It works on all 1.5 versions including 1.5.6.4.

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 wafflemeister » Sun Jan 19, 2025 1:10 am

Cue4cheap wrote:
Sat Jan 18, 2025 10:22 pm
wafflemeister wrote:
Sat Jan 18, 2025 3:55 am
I run Opencart 1.5.6.4. I would like to modify the weight based shipping module. The modification should check the cart content for product ID and if let's say if product ID 0001 is in the cart I would like it to not show any of the weight based shipping options. Thank you in advance for your help!
How about by model?
in catalog/model/extension/shipping/weight.php

Code: Select all

$os = array("MODEL1", "MODEL2");
if (in_array($product['model'], $os)) {
$status = false;
}
Place before
if ($status) {

Mike
Thank you Mike!

I tried this but got the following error:

Notice: Undefined variable: product in ....public_html/catalog/model/shipping/weight.php on line 24

line 24 being:

Code: Select all

if (in_array($product['model'], $os)) {
I had replaced

Code: Select all

$os = array("MODEL1", "MODEL2");
with

Code: Select all

$os = array("actual_model_number");

Active Member

Posts

Joined
Fri Jun 21, 2013 11:10 pm

Post by Cue4cheap » Sun Jan 19, 2025 2:44 am

Sorry but that was from memory... which is getting bad for the older versions...
In /catalog/model/shipping/weight.php
Put somewhere, maybe after: $this->language->load('shipping/weight');

$os = array("MODEL1", "MODEL2");
That needs to be the model of the product(s) you wish to have this act on

Code: Select all

foreach ($this->cart->getProducts() as $product) {
if (in_array($product['model'], $os)) {
$status = false;
}
}

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by paulfeakins » Mon Jan 20, 2025 6:39 pm

Johnathan wrote:
Sat Jan 18, 2025 11:20 pm
If you don't want to have to modify code yourself, my Category & Product-Based Shipping (https://www.getclearthinking.com/catego ... d-shipping) extension can do this. It works on all 1.5 versions including 1.5.6.4.

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.
In my opinion you should definitely use Johnathan's extension rather than start tweaking the code yourself.

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 Johnathan » Mon Jan 20, 2025 11:27 pm

Thanks for the vote of confidence. ;D However, Mike's solution should work as well, as long as you're willing to edit the file and hard-code the model values yourself.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by paulfeakins » Tue Jan 21, 2025 7:49 pm

Johnathan wrote:
Mon Jan 20, 2025 11:27 pm
Thanks for the vote of confidence. ;D However, Mike's solution should work as well, as long as you're willing to edit the file and hard-code the model values yourself.
True but your extensions could then do a lot more in future if required!

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
Who is online

Users browsing this forum: clivem and 25 guests