Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Pass order no. in a link to external script Rate Topic   - - - - -

 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 102 posts

Posted 15 May 2013 - 08:21 AM #1

Hi, I want to create a link in the order confirmation template (post checkout) that will pick up some variables to pass to own script. As a minimum I need to pick up the order number i.e.

<a href="https://mydomain/path/to/my/script.php?on={$order_number}&u={$auth.info.user_id}&action=doConfig">Now go to the blah blah configuration</a>

I've only used psuedo examples above, not real CS-Cart variables!

Help would be appreciated - tight timeline...

 
  • CS-Cart team
  • CS-Cart support team
  • Moderators
  • Join Date: 04-Apr 11
  • 3809 posts

Posted 15 May 2013 - 10:48 AM #2

Hello Wilko,

Thank you for your message.

If you use this link on the order landing page or order details page in the storefront, you will need to use the {$order_info.order_id} Smarty variable to get an order ID. Please check it.

Thank you.

---
Pavel Zyukin
CS-Cart Support team

Sincerely yours, CS-Cart Support Team

 

User guide       |  Developer documentation  |  Core API documentation


 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 102 posts

Posted 15 May 2013 - 11:06 AM #3

Thanks Pavel,

Since original post I have decided a better way is to scrub the above in terms of link location - I would rather place the link in the 'Account Info' block as something like 'My Config' which just passes the user id to the script. I assume (although perhaps a dangerous assumption!) that user ids never get re-used if a user is deleted..!

I have successfully added a link as list item within a smarty {if $auth.user_id && $auth.user_id==2} so that it only displays for my 'test user' for the moment. I can pass the variables via GET or POST (if I make a little form with hidden fields) so this is all ok.

My only issue now is that I am using a custom block/template on the target page which detects if user logged in etc. so they get a nice system message rather than a '404' error. The custom block loads my script into an iframe if the $auth.user_id condition is true.

My challenge now is to get the variables passed by my link in the my_account.tpl template link though the custom block to the script which loads in the iframe!!!

The process will need to be:

1) Link in 'My Account' clicked > passes variables to 2) the 'content page' which contains the custom block/template and then pass the variables on to 3) the script.php that that is called into the iframe.

I think it's quite simple but just need to know what smarty variables are available to the custom page at stage 2 i.e. $auth.user_id etc. If user id, firstname, lastname etc. are available then I won't even need to include any variables in the my_account.tpl link.

 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 102 posts

Posted 15 May 2013 - 11:34 AM #4

Ok, to simplify my need - I think that I just need a template hook to declare in my custom template to pull in the user info variables - is it
{hook name="profiles:my_account_menu"}?

Could do with a list somewhere of what to call and variable names?

I need to access the logged-in user's profile data - at least id, firstname, lastname, email address/username

Your help is always appreciated!

 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 102 posts

Posted 15 May 2013 - 03:04 PM #5

Ok, so I found the answer myself and posting back as, although it may seem really obvious, er, kind of took me a while to get it... and it might help someone else looking for the same answer.

{foreach from=$user_info key=k item=v}
   <li>{$k}: {$v}</li>
{/foreach}

outputs:
  • user_id: 2
  • user_login: user_2
  • company_id: 0
  • firstname: Bilbo
  • lastname: Baggins
  • email: bilbo.baggins@middle.earth
  • user_type: C

So, there I have it... {$user_info.firstname} blah blah...

<a href="https://some.custom.link/script.php?U={$user_info.user_id}">My Link To Custom Non CS-Cart Script</a>

Does the job...

 
  • CS-Cart team
  • CS-Cart support team
  • Moderators
  • Join Date: 04-Apr 11
  • 3809 posts

Posted 16 May 2013 - 11:25 AM #6

Hello Wilko,

I am glad to hear you managed to resolve the problem. Thank you for keeping me informed.

---
Pavel Zyukin
CS-Cart Support team

Sincerely yours, CS-Cart Support Team

 

User guide       |  Developer documentation  |  Core API documentation