Page 1 of 1
[Request] Free shipping for default customer group only
Posted: Mon Jan 16, 2012 8:47 pm
by pratik.shah
Greetings to all,
I want to customize built-in free shipping over $xxx limiting to only default group of customers.
Can anyone help me with the code to be added to php?
Re: [Request] Free shipping for default customer group only
Posted: Mon Jan 16, 2012 10:14 pm
by webvet
Have you looked at this extension
http://forum.opencart.com/viewtopic.php?f=124&t=39792? It links shipping options to customer group.
Or for more options try putting
shipping based on customer group
into the search facility
Re: [Request] Free shipping for default customer group only
Posted: Wed Apr 01, 2015 4:03 pm
by nitsak
Hi, I just had the same request and buying an extension seemed extreme. Here's what I found to work on my site (1.5.5.1)
Open "Catalog/model/shipping/free.php" and go to line 19, between:
Code: Select all
if ($this->cart->getSubTotal() < $this->config->get('free_total')) {
$status = false;
}
and
Now we want to add another condition to stop keep the option disabled (the bottom if statement on the php file makes it enabled)
Paste the following just above the "$method_data = array();":
Code: Select all
if ($this->customer->getCustomerGroupId() <> 1) {
$status = false;
}
The assumption here is that you will only be allowing free shipping to the default customer group (id =1), you can modify the if statement to suit your requirements.
Hope this helps
Re: [Request] Free shipping for default customer group only
Posted: Sat Sep 24, 2016 6:53 am
by jkitz
Just wondering if there may be an equivalent to this for 2.3?
When I try this method it informs me that the getCustomerGroupId() function doesn't exist.
The relevant file is in a different location of course:
catalog/model/extension/shipping/free.php
Re: [Request] Free shipping for default customer group only
Posted: Sat Sep 24, 2016 11:11 pm
by Johnathan
That function was renamed a few versions ago. Using this edit should work:
Code: Select all
IN:
/catalog/model/extension/shipping/free.php
BEFORE:
if ($status) {
ADD:
if ($this->customer->getGroupId() != 1) {
$status = false;
}
Re: [Request] Free shipping for default customer group only
Posted: Sun Sep 25, 2016 12:09 pm
by jkitz
Johnathan wrote:That function was renamed a few versions ago. Using this edit should work:
Code: Select all
IN:
/catalog/model/extension/shipping/free.php
BEFORE:
if ($status) {
ADD:
if ($this->customer->getGroupId() != 1) {
$status = false;
}
Thanks Johnathan, this worked like a charm.