Jump to content

how can i maintain variable in URL when location is change?


Recommended Posts

Hi,

 

before user registration and before enter on the shop i need select user group:

 

student? - profesor? - institution?

 

after select id group i want send this variable on every page on PS for load categories, content and prices for this group. user can go back and select other id group and load other categories, other content and other prices.

 

http://www.i-culture-online.com/tienda/es/?ig=5

 

in first load i send /?ig=5  (id_group = 5), and i load content as id group 5 but when i change category or product, variable "ig" is disappear.

 

in class/group.php i change this line

 

if (Validate::isLoadedObject($customer))
            $id_group = (int)$customer->id_default_group;
        else
            $id_group = $_GET["ig"];

 

// when id group is not defined, get id group from URL

 

but how i can maintain this variable in URL when location is change?

 

thank you for any answer, best regards, Jozef

 

Link to comment
Share on other sites

when they select group you should just update the customer object with the new group.  You will not be able to carry the variable as described without a lot of changes.  So simply changing the value used by Prestashop I think would be cleaner.

$this->context->customer->id_default_group = (your group value);
Link to comment
Share on other sites

but, when customer is conected there is her selected group in her account.

 

i need show diferents groups before registration

i solved it with cookie, but i would like know how make it without cookies

 

in group.php i changed this:

 

        $xig = $_GET["ig"];
            
         if($xig>0){
         $cookie = Context::getContext()->cookie;
        $cookie->cookieGroup = $xig;
         }else{
        $cookie = Context::getContext()->cookie;
        $xig = $cookie->cookieGroup;
         }

        $id_group = $xig;

you can try it how work with ?ig=4, ?ig=5, ?ig=6 (three diferent group id)

 

http://www.i-culture-online.com/tienda/es/16-productos?ig=5

 

changed price in first product "i-passport Español"

 

with cookie i can maintain inicial var "ig" in all pages. when variable "ig" is changed in URL, then all pages get other group.

this is the idea, but i like it make without cookies.

 

thank you for your time

Link to comment
Share on other sites

where is:

 

$this->context->customer->id_default_group = (your group value);

 

what file?

 

this is part of PrestaShop context, you can learn about context here: http://doc.prestashop.com/display/PS15/Using+the+Context+Object

this is for 1.5 but applies to 1.6

 

so if you create a module that allows select of group, then the module would change the value.

 

of course this is a suggestion on another way to do it, I just don't know how you can easily main maintain the url

 

here is an example paid module, http://www.prestashop.com/forums/topic/116742-module-customer-group-select-during-registration/

 

but creating a module to change group would be very simple.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...