Post by mukur » Thu Feb 28, 2019 7:51 am

Opencart Version 2.3.0.2 - currently using Vqmod (below) to hide other shipping when free shipping is active. I am looking to adapt it to also hide free shipping if active for a particular Customer group = '2" (i.e. Wholesale customers will not see\be allowed free shipping option).


<file path="catalog/model/extension/shipping/*.php">
<operation error="skip">
<search><![CDATA[if ($status) {]]></search>
<add position="before"><![CDATA[
if (get_class($this)!='ModelExtensionShippingFree') {
if (($this->config->get('free_status') == 1) && (float)$this->cart->getTotal() >= $this->config->get('free_total')) {
$status = false;
}
}
]]></add>
</operation>
</file>

Currently going round in circles, should be fairly simple but unfortunately cant crack it - any help would be appreciated.

Cheers

Newbie

Posts

Joined
Fri Sep 07, 2012 9:55 am

Post by straightlight » Thu Feb 28, 2019 8:10 am

From the provided XML code, replace:

Code: Select all

if (get_class($this)!='ModelExtensionShippingFree') {
if (($this->config->get('free_status') == 1) && (float)$this->cart->getTotal() >= $this->config->get('free_total')) {
$status = false;
}
}
with:

Code: Select all

$this->load->model('account/customer_group');

$customer_groups = $this->model_account_customer_group->getCustomerGroups();

$customer_group_ids = array_column($customer_groups, 'customer_group_id');

$customer_group_ids_intersect = array_intersect($customer_group_ids, array(2)); // You can add more IDs here.

if (((!$this->config->get('free_status')) || ($this->config->get('free_status') && (float)$this->cart->getTotal() > $this->config->get('free_total') && (in_array($this->config->get('config_customer_group_id'), (array)$customer_group_ids_intersect))))) {
	$status = false;	
}
Last edited by straightlight on Fri Mar 01, 2019 7:47 am, edited 2 times in total.

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 mukur » Thu Feb 28, 2019 10:40 am

Thanks Straightlight

Going in the right direction tried your code but unfortunately does not quite do what I want

For:
Default Customer - does not hide other shipping methods when "free shipping" is available

Wholesale above free shipping limit get the message "Warning: No Shipping options are available. Please contact us for assistance!" rather than showing the shipping methods available i.e "weight based"

Cheers

Newbie

Posts

Joined
Fri Sep 07, 2012 9:55 am

Post by straightlight » Thu Feb 28, 2019 8:33 pm

mukur wrote:
Thu Feb 28, 2019 10:40 am
Thanks Straightlight

Going in the right direction tried your code but unfortunately does not quite do what I want

For:
Default Customer - does not hide other shipping methods when "free shipping" is available

Wholesale above free shipping limit get the message "Warning: No Shipping options are available. Please contact us for assistance!" rather than showing the shipping methods available i.e "weight based"

Cheers
The default customer group was not mentioned in your topic subject nor on the first post. As for the wholesale, it doesn't explain much other than what the customer group name is according to your first post. However, not to hide other shipping methods when free shipping is available would need to be done from the controllers, not from the models. You're simply on the wrong location to set the conditionings.

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 mukur » Fri Mar 01, 2019 4:03 am

Thanks again for input Straightlight

Apologies if my posts were confusing. The vqmod code posted in my 1st post actually successfully manages to hide other shipping methods when free shipping level is reached for both default and wholesale customers. I thought it would just be a simple tweak to get it so that free shipping would not apply(or be hidden) for Wholesale customers.

Cheers,

Update: pretty easy fix in the end just needed to include an "else if " in the code but took me a hell of a time and frustration to figure it out - hope it helps someone else

Code: Select all

if ($this->customer->getGroupId() != 1) {
            } elseif 

Newbie

Posts

Joined
Fri Sep 07, 2012 9:55 am

Post by rebelo » Sun May 12, 2019 1:36 pm

Hi.

This might be what i have been looking for for a long time.
In Opencart 2.1.0.2 i need to hide at checkout payment_B when payment_A is also available.

Got so far

Code: Select all

<file name="catalog/model/payment/*.php">
		<operation error=skip">
			<search position="before"><![CDATA[
			if (get_class($this)!='ModelPayment_A')
			
Any help for the rest pls.
Last edited by straightlight on Fri Jan 31, 2020 11:26 am, edited 1 time in total.
Reason: Added code tags.

Newbie

Posts

Joined
Fri Apr 13, 2018 2:41 am

Post by rebelo » Mon May 13, 2019 2:14 am

Still not working
<file name="catalog/model/payment/*.php">
<operation error="skip">
<search><![CDATA[if ($status) {]]></search>
<add position="before"><![CDATA[
if (get_class($this)!='ModelPaymentMultibanco') {
($this->config->get('bank_transfer'){
$status = false;
}
}
]]></add>
</operation>
</file>
</modification>

Newbie

Posts

Joined
Fri Apr 13, 2018 2:41 am

Post by rebelo » Tue May 14, 2019 3:13 am

Hi.

Solved with Restrict Payment Methods.

Rebelo

Newbie

Posts

Joined
Fri Apr 13, 2018 2:41 am
Who is online

Users browsing this forum: No registered users and 26 guests