News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Bug/feature request and patch: Set Default Country to match Shop Location

Started by thebeuving, May 16, 2012, 23:18:18 PM

Previous topic - Next topic

thebeuving

Virtuemart 2.0.6 doesn't set the shops location to be the default country on check out. Since this was the functionality in VM1 and several people are requesting it I have created a patch to solve this problem in hopes that it could be put in the code base for the next release.

The 2 patches need to be applied to
administrator/components/com_virtuemart/models/userfields.php
and
administrator/components/com_virtuemart/controllers/user.php

Let me know if you have any questions.

Thanks,
David

[attachment cleanup by admin]
Founded in 2005, Khoza Technology, Inc. formerly SRI Hosting, Inc. is an IT services company with proven success building hosted services, applications, and websites.

https://khoza.com

thebeuving

Founded in 2005, Khoza Technology, Inc. formerly SRI Hosting, Inc. is an IT services company with proven success building hosted services, applications, and websites.

https://khoza.com

totallnet

thebeuving

Joomla 2.5.4
VM 2.0.6

In backend i set the shop location as Brazil and tried your both tips but failed.

UPDATE brsist_virtuemart_userfields SET `default`=(SELECT virtuemart_country_id FROM brsist_virtuemart_countries WHERE country_name='Brazil') WHERE name='virtuemart_country_id';

and then ... removing back the virtuemart_country_id to NULL tried uploading the 2 files..

What can i do ..

Thanks in advance

Kazuo

thebeuving

What is the result for the inner query:

QuoteSELECT virtuemart_country_id FROM brsist_virtuemart_countries WHERE country_name='Brazil';

If that is a valid number greater than 0 then it should have worked, I would suggest running the query again, my try clearing your browser cache before hitting the check out to make sure the defaults aren't being cached.

Thanks,
David
Founded in 2005, Khoza Technology, Inc. formerly SRI Hosting, Inc. is an IT services company with proven success building hosted services, applications, and websites.

https://khoza.com

serapol

There is a correct solution to this problem. In Virtuemart already incorporated this functionality but for some reason has not been used since the time of Virtuemart 1.0.

It is necessary to make two small changes
1. In the file administrator/components/com_virtuemart/views/userfields/tmpl/edit.php find the line

<?php echo $this->lists['published']; ?>


and after adding

<?php echo VmHTML::row('input','COM_VIRTUEMART_CUSTOM_DEFAULT','default',$this->userField->default,'class="inputbox"','',40); ?>


2. In the file administrator/components/com_virtuemart/tables/userfields.php find the line

$reqValues = array('select', 'multiselect', 'radio', 'multicheckbox');


and after adding

$ignoreName = array('virtuemart_country_id', 'virtuemart_state_id');


and change line

if (in_array($this->type, $reqValues) && $nrOfValues == 0) {


in the

if (in_array($this->type, $reqValues) && !in_array($this->name, $ignoreName) && $nrOfValues == 0) {


This change needs to be done because there is a check the availability of additional values ​​for the field type select, and in the fields of country and state we do not need

Since this functionality is not used for obvious reasons, the field does not default in the database, an int. It needs to be replaced with char(255), so that you can add default values ​​for each field type.
To execute the query in phpmyadmin

ALTER TABLE `PREFIX_virtuemart_userfields` CHANGE `default` `default` CHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL


Now that you appear at the bottom when editing custom fields, another option is "default", there you can write any value for any field. For fields of the country and state must be entered ID

celticwebs

Quote from: serapol on May 21, 2012, 20:16:49 PM
There is a correct solution to this problem. In Virtuemart already incorporated this functionality but for some reason has not been used since the time of Virtuemart 1.0.

It is necessary to make two small changes
1. In the file administrator/components/com_virtuemart/views/userfields/tmpl/edit.php find the line

<?php echo $this->lists['published']; ?>


and after adding

<?php echo VmHTML::row('input','COM_VIRTUEMART_CUSTOM_DEFAULT','default',$this->userField->default,'class="inputbox"','',40); ?>


2. In the file administrator/components/com_virtuemart/tables/userfields.php find the line

$reqValues = array('select', 'multiselect', 'radio', 'multicheckbox');


and after adding

$ignoreName = array('virtuemart_country_id', 'virtuemart_state_id');


and change line

if (in_array($this->type, $reqValues) && $nrOfValues == 0) {


in the

if (in_array($this->type, $reqValues) && !in_array($this->name, $ignoreName) && $nrOfValues == 0) {


This change needs to be done because there is a check the availability of additional values ​​for the field type select, and in the fields of country and state we do not need

Since this functionality is not used for obvious reasons, the field does not default in the database, an int. It needs to be replaced with char(255), so that you can add default values ​​for each field type.
To execute the query in phpmyadmin

ALTER TABLE `PREFIX_virtuemart_userfields` CHANGE `default` `default` CHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL


Now that you appear at the bottom when editing custom fields, another option is "default", there you can write any value for any field. For fields of the country and state must be entered ID


Just so everybody knows you have to enter the country ID number I.e. US is 223 UK is 222 Aus is 13 etc  etc.  You can find these by checking them in the SQL under virtuemart_userfields

webbits