Post by golive69 » Sun Oct 17, 2021 9:10 am

OC 2.3.0.2
I want to show info to a geo zone group. The sample code below works for customer group.

Code: Select all

<?php if($this->customer->getGroupId() == 3) { ?>
<h3 style="text-align: center;">
<?php 
$total = $this->cart->getTotal();
$sum = (75-$total);	  
if ($total >= 75) {
echo "¡Gracias por tu pedido, obtienes <b>ENVÍO GRATIS!</b>"; }
else { 
echo  "¡Agregue US$".$sum." a su carrito para <b>ENVÍO GRATIS!</b>"; 
}	  
?>
</h3><br>
<?php } ?>
Also can I insert another group ID where I show 3 above?
Last edited by golive69 on Tue Oct 19, 2021 12:37 am, edited 1 time in total.

User avatar
Newbie

Posts

Joined
Thu Mar 18, 2021 1:36 am
Location - BC, Mexico

Post by straightlight » Sun Oct 17, 2021 11:28 am

golive69 wrote:
Sun Oct 17, 2021 9:10 am
OC 2.3.0.2
I want to show info to a geo zone group. The sample code below works for customer group.

Code: Select all

<?php if($this->customer->getGroupId() == 3) { ?>
<h3 style="text-align: center;">
<?php 
$total = $this->cart->getTotal();
$sum = (75-$total);	  
if ($total >= 75) {
echo "¡Gracias por tu pedido, obtienes <b>ENVÍO GRATIS!</b>"; }
else { 
echo  "¡Agregue US$".$sum." a su carrito para <b>ENVÍO GRATIS!</b>"; 
}	  
?>
</h3><br>
<?php } ?>
Also can I insert another group ID where I show 3 above?
For multiple customer groups, replace:

Code: Select all

<?php if($this->customer->getGroupId() == 3) { ?>
with:

Code: Select all

<?php

$customer_group_data = array(
	1,
	2,
	3
);

if (in_array($this->customer->getGroupId(), $customer_group_data)) {
?>
You can, then, replace 1,2,3 with the specific groups.

As for the geo zone ID from the customer, this might be a bit more complexed. The portion of the code you might be looking for to integrate:

Code: Select all

<?php
    $this->load->model('account/address');
    
    $address_info = $this->model_account_address->getAddress($this->customer->getAddressId());
    
    if ($address_info->num_rows) {
        $geo_zones = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` ztgz INNER JOIN `" . DB_PREFIX . "geo_zone` gz ON (ztgz.`geo_zone_id` = gz.`geo_zone_id`) WHERE ztgz.`zone_id` = '" . (int)$address_info->row['zone_id'] . "' AND ztgz.`country_id` = '" . (int)$address_info->row['country_id'] . "'");
        
        if ($geo_zones->num_rows) {
            	$geo_zone_data = array(
            		1,
            		2,
            		3
            	);
            	
            	foreach ($geo_zones->rows as $result) {
            	    if (in_array($result['geo_zone_id'], $geo_zone_data)) {
            	    
            	    }
            	}
        }
    }
?>
Do the same to customize your 1,2,3 in the $geo_zone_data . However, what you are requesting should be done in the controller by using an Event trigger rather than playing directly in your TPL file as it is not recommended.

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 golive69 » Mon Oct 18, 2021 6:38 am

Awesome, Thank you straightlight, I knew that if someone would be willing to help that it would be you.
The multiple customer groups WORKS. But sadly the get customer geo zone ID does not.

Code: Select all

However, what you are requesting should be done in the controller by using an Event trigger rather than playing directly in your TPL file as it is not recommended.
I know I was going to get some tongue on that one at the least :)
The truth is I am a bit old fashion. I am using this code in my modified HTML Content Module that supports PHP and what ever I feed it (I also use language specific PHP include, to display more complex content.

Anyway if you don't mine and have the time, could you show us the proper way to get the customer geo zone ID using the Controller and View.

User avatar
Newbie

Posts

Joined
Thu Mar 18, 2021 1:36 am
Location - BC, Mexico

Post by straightlight » Mon Oct 18, 2021 10:06 pm

golive69 wrote:
Mon Oct 18, 2021 6:38 am
Awesome, Thank you straightlight, I knew that if someone would be willing to help that it would be you.
The multiple customer groups WORKS. But sadly the get customer geo zone ID does not.

Code: Select all

However, what you are requesting should be done in the controller by using an Event trigger rather than playing directly in your TPL file as it is not recommended.
I know I was going to get some tongue on that one at the least :)
The truth is I am a bit old fashion. I am using this code in my modified HTML Content Module that supports PHP and what ever I feed it (I also use language specific PHP include, to display more complex content.

Anyway if you don't mine and have the time, could you show us the proper way to get the customer geo zone ID using the Controller and View.
You could gather an e.g from your catalog/controller/extension/advertise/google.php file on how to use an /after event. As for the documentation: https://github.com/opencart/opencart/wiki/Events-System which shows how to trigger a /before and /after altogether.

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 golive69 » Mon Oct 18, 2021 11:42 pm

Ok I read the article But sadly I'm not a programmer. I am only able to hack, cut, paste, learn by example, and most of all be creative (or steal from other mods and try to readapt for my needs) :)

Thanks straightlight for your willingness to assist your a true asset to OC.
Last edited by golive69 on Tue Oct 19, 2021 12:12 am, edited 2 times in total.

User avatar
Newbie

Posts

Joined
Thu Mar 18, 2021 1:36 am
Location - BC, Mexico

Post by straightlight » Mon Oct 18, 2021 11:53 pm

golive69 wrote:
Mon Oct 18, 2021 11:42 pm
Ok I read the article But sadly I'm not a programmer. I am only able to hack, cut, paste, learn by example, and most of all be creative (or steal from other mods and try to readapt for my needs) :)

Thanks straightlight for your willingness to assist your a true asset to OC.
Since you have the will to steal from other mods, the extension I referred on the above to accomplish this with a Save As along with the ... cut, paste and learn process should do just fine.

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 golive69 » Tue Oct 19, 2021 12:24 am

As a work-around I guess I could create geo user groups, on the downside I will need to set same product price for each group.
The file catalog/controller/extension/advertise/google.php does not exist in my setup.

In my example above that would be used on the checkout page probably already has all the code and just need to call it. If I was a good programmer I would call the "free shipping amount" so not forget to edit my code should that amount change in the future. While many programmers view code and it all makes sense. I am still trying to decide if I enjoy sucking on my left thumb or my right.

Thank you

User avatar
Newbie

Posts

Joined
Thu Mar 18, 2021 1:36 am
Location - BC, Mexico

Post by straightlight » Tue Oct 19, 2021 3:10 am

golive69 wrote:
Tue Oct 19, 2021 12:24 am
As a work-around I guess I could create geo user groups, on the downside I will need to set same product price for each group.
The file catalog/controller/extension/advertise/google.php does not exist in my setup.

In my example above that would be used on the checkout page probably already has all the code and just need to call it. If I was a good programmer I would call the "free shipping amount" so not forget to edit my code should that amount change in the future. While many programmers view code and it all makes sense. I am still trying to decide if I enjoy sucking on my left thumb or my right.

Thank you
As long as you're not referring to the middle one since the forum doesn't need to know that.

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 straightlight » Tue Oct 19, 2021 5:09 am

In addition, to manipulate prices such ways, with the use of customer groups, better to add a GDPR / CCPA / CCRA terms and agreement extension if guests can purchase during checkout. Otherwise, store owners using shipping for, either, physical / virtual products as well as recurring products may be affected with their recurring prices during the order 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
Who is online

Users browsing this forum: No registered users and 67 guests