Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Getting variables from link clicked

Getting variables from link clicked

Started by ebaobao on 16 Sep 2011, 12:18 AM · Views: 1,103

Results 1 to 16 of 16
16 Sep 2011, 12:18 AM
#1
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #1 by ebaobao

Hello,
I don't know where to post for this question. Basically, I want to perform a certain action on tpl_login_default.php based on where the customer came from. So far they either come from
Login: http://www.meaningfulaccents.com/index.php?main_page=login

or

Continue checkout on Shopping cart: http://www.meaningfulaccents.com/index.php?main_page=checkout_shipping

I was thinking of using main_page as an argument, but I don't know how to pass it all the way to tpl_login_default.php. So then I tried to grab the previous clicked link and just do my conditional statements from that but I don't know how to do that either. Anyone can help? Thanks.

16 Sep 2011, 12:44 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #2 by drbyte

Why ?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Sep 2011, 3:31 AM
#3
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #3 by ebaobao

Hi Dr. Byte,
The reason is because I want to display certain words/sentences and button when they are doing a proceed to checkout as oppose to when they want to login/create account. All this of course being for user friendly experience for customers. For example, I've decided to remove the paypal EC button from that page because I find it weird to present it twice once on shopping cart and then again after they click proceed to checkout. If you want me to go more into detail, let me know. Thank you for your help.

16 Sep 2011, 5:29 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #4 by drbyte

<?php if ($_SESSION['cart']->count_contents() > 0) { then there's something in their cart so it's likely they've arrived with intent to checkout }

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Sep 2011, 7:40 PM
#5
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #5 by ebaobao

Hi Dr. Byte,

Thank you. However, that would still not satify the condition where they are in their shopping cart and then click on the login link. I want login to be very distinct from proceed to checkout whenever they click the login link. Any other ideas? Thanks again.

16 Sep 2011, 10:31 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #6 by drbyte

If they're in their shopping cart and click the login link, then they'll have something IN their cart, and thus the code I posted will work.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Sep 2011, 2:22 AM
#7
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #7 by ebaobao

Hi Dr. Byte,
I appreciate the help. Thank you. I understand what you mean. Maybe I'm not being clear about what I want, so let me try again. Lets take the case where the user has added an item to their cart.

  1. after adding, the user is at the shopping cart page.

  2. Now from there, the user can click proceed to checkout or the login link in the header.

  3. currently, the behavior is that both of those links will give the exact same login page because ZC recognizes that the cart has an item. that is NOT what i want.

  4. for example, if the user clicks on login link, I don't care what they are doing or where they are at or even if there is an item in cart or not. I will just present to them ONLY the username & password fields. I DON'T want to show the user the new customer? sign up stuff.

  5. if they click on proceed to checkout, then I will include the new customer? sign up stuff and also the username & password fields to the right.

hope this is a little more clear. Thank you for your help again. Any suggestions?

17 Sep 2011, 6:19 AM
#8
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #8 by ebaobao

Here is a better example. When a user clicks login or my account, it brings up the exact same login page.
login url: http://www.website.com/index.php?main_page=login
my account url: http://www.website.com/index.php?main_page=account.
I don't want the same thing for those links. for my account link i want the login page to only display username/password fields. since they want to go to their account, it doesn't make sense to ask them if they are a new user and if they want to sign up since they have an account already. I want to recognize where the user came from by what link they clicked on and display the login page with specific info based on where they came from. That is why I was planning to use the main_page parameter in the url for my if/else statements. What would be the best approach for this? Thanks.

17 Sep 2011, 5:13 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #9 by drbyte

So, you're saying that if I come along as a new customer to your shop and want to create an account, and the only remotely close option I have for that is your "Login" link, and I click that, you're NOT going to give me the option to create an account? Doesn't seem very intuitive.

Why are your customers bothered by seeing the option to register beside the login fields? Especially when the cursor is already set into the username login field ready for them to proceed with login easily?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Sep 2011, 5:30 PM
#10
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Post #10 by schoolboy

The argument for your desired functionality lacks logic and common sense...

The system has no way of knowing whether a visitor is an existing customer, or a new customer, when they click "checkout".

(As it is about to become illegal - in the EU - to set such cookies, using this method to remember a customer is no an option).

I do not know of any web shopper who has been "offended" when presented with both LOGIN and REGISTER invitations.

People are not stupid... they will know which one to select...

20 years a Zencart User

18 Sep 2011, 5:32 AM
#11
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #11 by ebaobao

DrByte:

So, you're saying that if I come along as a new customer to your shop and want to create an account, and the only remotely close option I have for that is your "Login" link, and I click that, you're NOT going to give me the option to create an account? Doesn't seem very intuitive.

Why are your customers bothered by seeing the option to register beside the login fields? Especially when the cursor is already set into the username login field ready for them to proceed with login easily?

Hi Dr. Byte,

Thank you for your reply. That may not necessarily be what I will be doing, was just example. What I really will consider doing is this on the login page:

  1. If user comes to the login page by clicking on login, then I would keep the sign up button saying sign up.

  2. However if they come to the login page by clicking on proceed to checkout, I would like to change the 'sign up' button to a button that says 'continue checkout' along with modifying the text

"'Create a Customer Profile with Meaningful Accents which allows you to shop faster, track the status of your current orders, review your previous orders and take advantage of our other member's benefits." to something different. Thanks again.

18 Sep 2011, 5:36 AM
#12
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #12 by ebaobao

schoolboy:

The argument for your desired functionality lacks logic and common sense...

The system has no way of knowing whether a visitor is an existing customer, or a new customer, when they click "checkout".

(As it is about to become illegal - in the EU - to set such cookies, using this method to remember a customer is no an option).

I do not know of any web shopper who has been "offended" when presented with both LOGIN and REGISTER invitations.

People are not stupid... they will know which one to select...

Hi Schoolboy,

I know what you mean. I'm just being extra picky on the text I want to show depending on what link they come from.

18 Sep 2011, 12:27 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #13 by drbyte

Then modify your login link and add something like &upsell=yes and check for $_GET['upsell'] == 'yes' in your login page and take action accordingly.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Sep 2011, 3:46 AM
#14
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #14 by ebaobao

Hi Dr. Byte,
Thanks for the help. But I am running into the same problem as before. Here is what is happening:

  1. In my login link I have http://www.meaningfulaccents.com/index.php?main_page=login&from_event=login

  2. In my My Account link I have
    http://www.meaningfulaccents.com/index.php?main_page=account&from_event=login

however the only time the from_event parameter ever gets passed over to tpl_login_default.php is when I click on login.

I have this in my tpl_login_default.php

$user_action = $_GET['from_event'];

if ($user_action == 'login') {
echo 'Create New Account?';
}
else {
 echo HEADING_NEW_CUSTOMER_SPLIT; }

it should trigger whether I click login or my account, but that is not the case. for some reason when I click my account link it drops the parameter. What is going on?

19 Sep 2011, 12:26 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #15 by drbyte

The My Account page redirects to login because the customer hasn't logged in yet. You'll need to change that redirect to add your extra parameter there too.
This is really looking like serious overkill.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Sep 2011, 4:52 PM
#16
ebaobao avatar

ebaobao

Zen Follower

Join Date:
Jul 2008
Posts:
495
Plugin Contributions:
0

Post #16 by ebaobao

Thanks Dr. Byte,
I'm sorry for so much trouble. I don't know how and where the redirects are. But, I'll just let this thread be and forget about it. Hopefully, I'll mustard up the courage some day and finish my goal. I appreciate all the help you have given.