Jump to content

Product available depending on the customer


thomasjrsn

Recommended Posts

Hi,

I'm using prestashop 1.7.5.2.

I try to make products available according to the customer, for example his email address. That means that if the email address matches, the customer will be able to add the product to his cart otherwise he will not be able to, and of course if the customer is not logged in he will not be able to access the product either. I tried to solve this problem based on the operation set up when a product is out of stock, and I only managed to block the product but I can't take the customer into account.

In the file ProductLazyArray.php and in the function addQuantityInformation:

if($this->product['id_product']==16){
$this->product['availability_message'] = 'Test error message';
$this->product['availability'] = 'unavailable';
}

Returns an error message and makes the product unavailable, and in product-add-to-cart.tpl:

<div class="add">
          <button
            class="btn btn-primary add-to-cart"
            data-button-action="add-to-cart"
            type="submit"
            {if !$product.add_to_cart_url}
              disabled
            {elseif $product.availability=='unavailable'}
              disabled
            {/if}
          >

If the product is unavailable, disable the Add to Cart button.

I block on making a product unavailable depending on the customer, because I don't see how to access the customer from ProductLazyArray.php.

I hope I explained my problem well, I don't really know if I'm on the right track for my problem so if you have any other leads I'll take.

Thank you in advance for your answers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...