Jump to content

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

Get Vendor's Administrator Id Rate Topic   - - - - -

 
  • hummer
  • Advanced Member
  • Members
  • Join Date: 23-Jul 20
  • 67 posts

Posted 23 November 2020 - 08:03 AM #1

Hi all!

 

Does anyone know how to obtain the cscart_users.user_id of the user who is currently logged in vendor adminstration (from php code)?

 

$Session[auth] is only reflecting customer not admin.

 

Looking forward to your answer.

 

Best regards

hummer

 

 



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1344 posts

Posted 23 November 2020 - 10:44 AM #2

Hello

 

[auth] => Array
(
[area] => A
[user_id] => 5
[user_type] => V

..........

 

$_SESSION['auth'] contain user_id vendor admin as see above.

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • hummer
  • Advanced Member
  • Members
  • Join Date: 23-Jul 20
  • 67 posts

Posted 23 November 2020 - 11:06 AM #3

Hi Robert,

 

thanks for that quick reply. I think I have to explain more in detail what I am doing.

 

Vendor Tab "iFrame Test" opens an iFrame with source to an "own" PHP page (in root directory www/cscart/).

 

Code in this page is currently:

 

<?php

define('AREA', 'A');
require(dirname(__FILE__) . '/init.php');

echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>';

?>

 

But session[auth] is showing customer data (see screenshot). Do you know why?

 

iframe_test_tab.PNG

 

 

Looking forward to your answer.

 

Best regards

hummer

 

 



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1344 posts

Posted 23 November 2020 - 11:19 AM #4

Hello

 

When preparing an iframe link, you can pass user_id as a parameter. You can do it by adding in template e.g.
&vendor_user_id=$smarty.session.auth.user_id
 
NOT TESTED.
 
Best regards
Robert

Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • hummer
  • Advanced Member
  • Members
  • Join Date: 23-Jul 20
  • 67 posts

Posted 23 November 2020 - 11:30 AM #5

Cool idea, Robert!

 

But I can only pass static URL parameters as it is an Add-On. It allows to attach an iFrame to a vendor tab with a static URL only.

 

iframe_test_tab2.PNG

 

Is there no chance to get access from my.php to the CS-Cart environment (and $Session[auth])?

 

Best regards

hummer



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1344 posts

Posted 23 November 2020 - 11:49 AM #6

Hello

 

But you have to use this link somewhere. So you can type my.php?section = 123&vendor_user_id=[user_id] or whatever. And in the template, do a parsing of this link and substitute the necessary value from session.

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • hummer
  • Advanced Member
  • Members
  • Join Date: 23-Jul 20
  • 67 posts

Posted 23 November 2020 - 01:03 PM #7

Ah, understood!

 

Stated the link with placeholder "[user_id]" as proposed in the backend add-on configuration:

/../my.php?section=123&vendor_user_id=[user_id]

Changed the template code from

[...] src="{$field.values|trim}" [...] 

to 

[...] src="{$field.values|trim|replace:"[user_id]":$smarty.session.auth.user_id}" [...] 

Get of URL querystring "vendor_user_id" on my.php works!

 

Thank you!

 

But: this was an modification in the Add-On template. Is there a way not to perform this change directely in the Add-On template (e.g. via Mychanges Add-On)?

 

Best regards

hummer



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1344 posts

Posted 23 November 2020 - 01:09 PM #8

Hello

 

If the template doesn't have a hook, you can override template in for example my_changes addon or add your own hook if you don't want to overwrite it. But must remember that you added a hook and if the updates overwrite the template you will have to restore the hook.

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible