This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

HappyTiger

  • **
  • 9 posts
How can I get the seller's user type (b_company)?
« on: March 15, 2021, 10:03:28 AM »
I would like to change the behavior depending on the seller's user type in cart.php.
I think it can be implemented with code like this.
Code: [Select]
$user = User::newInstance()->findByPrimaryKey(osc_user_id());
if($user['b_company'] == 0 {

}
Thanks for your attention.

*

MB Themes

Re: How can I get the seller's user type (b_company)?
« Reply #1 on: March 15, 2021, 10:27:15 AM »
@HappyTiger
I would rather use:
Code: [Select]
osc_logged_user_id()
To get ID of user in cart.

Then, to be sure, on checking user type:
Code: [Select]
if(@$user['b_company'] != 1) {
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

HappyTiger

  • **
  • 9 posts
Re: How can I get the seller's user type (b_company)?
« Reply #2 on: March 15, 2021, 10:54:46 AM »
@MB Themes
Thank you for your response.
I can get the user type of the user who is operating the cart page with your code, but how do I get the user type of the seller who created the ad?
Code: [Select]
$userId = User::newInstance()->findByPrimaryKey(osc_logged_user_id());
if(@$user['b_company'] != 0) {

}

*

MB Themes

Re: How can I get the seller's user type (b_company)?
« Reply #3 on: March 15, 2021, 11:04:20 AM »
@HappyTiger
Code: [Select]
$itemUser= User::newInstance()->findByPrimaryKey(osc_item_user_id());
if(@$itemUser['b_company'] != 1) {

}

... take more attention to naming of your variables, as well that in PHP 8, 0 != '', null != 0 (I think), so it's better to check against 1.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

HappyTiger

  • **
  • 9 posts
Re: How can I get the seller's user type (b_company)?
« Reply #4 on: March 15, 2021, 12:17:36 PM »
@MB Themes
Thanks for the advice.
I think I'm not fully understanding the article.:-[

Nothing is displayed. $itemUser['b_company'] is empty.
Code: [Select]
$itemUser= User::newInstance()->findByPrimaryKey(osc_item_user_id());
echo $itemUser['b_company'];

Any user type react. :(
Code: [Select]
$itemUser= User::newInstance()->findByPrimaryKey(osc_item_user_id());
if(@$itemUser['b_company'] != 1) { }
« Last Edit: March 16, 2021, 04:01:16 AM by HappyTiger »

*

MB Themes

Re: How can I get the seller's user type (b_company)?
« Reply #5 on: March 15, 2021, 12:47:14 PM »
@HappyTiger
osc_item_user_id() must be used on places, where this function does something (inside item loops, on item page etc).
Using it on random place will most probably not work.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by HappyTiger on March 16, 2021, 05:04:03 PM
*

HappyTiger

  • **
  • 9 posts
Re: How can I get the seller's user type (b_company)?
« Reply #6 on: March 16, 2021, 03:26:04 AM »
@MB Themes
This problem was solved thanks to your support. :)

item-sidebar.php
Code: [Select]
session_start();
$itemUser = User::newInstance()->findByPrimaryKey(osc_item_user_id());
$_SESSION['itemUser'] = $itemUser['b_company'];
cart.php
Code: [Select]
if(@$_SESSION['itemUser'] != 1) { }
« Last Edit: March 16, 2021, 03:27:57 AM by HappyTiger »