Remove add to cart button depending on the vendor

  • Posts: 21
  • Thank you received: 0
10 years 5 months ago #160619

Hello

Is it possible to remove the add to cart button and the stock display for a product depending on the group of the vendor ?

ex : make that for all vendors belonging to group 'A' add to cart button and stock are not displayed ?

Which template should be edited ?

For instance can I add something with
if ( $vendor->user->usertype == "Registered" ) , then display or not

Thanks
Jean

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 5 months ago #160621

Hi,

In the HikaShop product views (product page and product listing) you have access to the product's vendor object.

So you can modify the view "product | quantity" to display or not the "add to cart" button or the stock depending the vendor.
You shoud use

$this->row->vendor
to access to the vendor of the processing product (if you are in a listing, the quantity view will be call for each product).

The vendor group is stored with the vendor access
$access = $this->row->vendor->vendor_access;
if(is_string($access))
  $access = explode(',', $access);
if(in_array('@3', $access)) { // @3 means the group with the id 3.
  // the vendor is in the group 3. Do some special stuff
}
The accesses starting with a @ are groups, otherwise it indicate the HikaMarket right (like "product_edit" or "order_listing").

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
10 years 5 months ago #161174

Thanks seems to work great...

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.058 seconds
Powered by Kunena Forum