How to use my own city auto-detection

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

How to use my own city auto-detection

Postby d0ublezer0 » Mon Oct 31, 2016 1:42 pm

Hello, everybody!
http://www.road.media

We use our own city auto-detection by IP. How can I pass it to the OPC?
It is important to use our own technology, since it is very specific.

We tried to transmit the data in this way (through a template index file):

Code: Select all
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT.'/administrator/components/com_virtuemart/helpers/config.php');
if(!class_exists('VirtueMartCart')) require(JPATH_ROOT.'/components/com_virtuemart/helpers/cart.php');
$geocart = VirtueMartCart::getCart();
$cartaddress["city"]=$found_city_name;
$cartaddress["zip"]=$found_city_post_code;
$geocart->saveAddressInCart($cartaddress, "ST");
$geocart->saveAddressInCart($cartaddress, "BT");


But it works only while the cart is not yet initialized.
If we put any product in the basket, then the code will no longer have any effect on the address.

Can you advise me?

Best regards, Anton
d0ublezer0
 
Posts: 14
Joined: Tue Mar 24, 2015 9:26 am

Re: How to use my own city auto-detection

Postby admin » Mon Oct 31, 2016 2:50 pm

hello anton, i replied to your email as well.

i suggest to attach your code to the OPC theme directly where you can display the values as needed and they also get stored within the cart for shipping and other usage.

you can alter the visitiblity and the cart within your theme here:

used for registration fields (email, username, etc.. ) and Bill to address section:
\components\com_onepage\themes\YOUR OPC THEME\overrides\list_user_fields.tpl.php

used for OPC registration overrride fields (mostly bill to address):
\components\com_onepage\themes\YOUR OPC THEME\overrides\list_user_fields_registration.tpl.php

used for shipping fields:
\components\com_onepage\themes\YOUR OPC THEME\overrides\list_user_fields_shipping.tpl.php

all 3 can be identical if needed.

see "three_column_special_blue" for example of altering html of the fields

example inside
switch( $field['name'] )
Code: Select all
case 'zip':
if (empty($cart->BT['zip'])) $cart->BT['zip'] = 123;
echo '<input type="text" value="<?php echo $cart->BT['zip']; ?>" name="zip" id="zip_field" required="required" />';
break;


best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: How to use my own city auto-detection

Postby d0ublezer0 » Sun Sep 16, 2018 12:01 pm

Cannot find, how to change $html from list_shipping_methods.tpl.php

Code: Select all
foreach ($shipping as $html)
{
  echo $html;
  $counter_payment++;
}


i want to add some styling to this code.
found shipping_methods.tpl.php, in tried to use them, but nothing happened, this file not used
d0ublezer0
 
Posts: 14
Joined: Tue Mar 24, 2015 9:26 am

Re: How to use my own city auto-detection

Postby admin » Thu Oct 25, 2018 12:51 pm

hello, each shipping and payment plugin renders it's html on it's own. so depending on what you want to do you can either modify the invividual plugins, or use javasript to inject information there or use opc's override system to modify it.

to completely override plugins html you can check the system at /components/com_onepagwe/overrides/third_party/shipment

and see how it modifies invividual plugins.

if you are using plugins from various vendors, the best way is to inject data via javascript via opc's events (after ajax / after shipping select / etc... ). for opc event's examples see intialization in some tabcontent.js files in opc themes.

if you want to modify the display of the city field, you may do so in list_user_fields(shipping/registration).tpl.php which renders the fields itself.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 3 on Joomla 3.x

cron