Back to PhocacartAccessRights class

Method canDisplayAddtocartStock

public
canDisplayAddtocartStock
(mixed $item, mixed $stock)

Method canDisplayAddtocartStock - Source code

/*
 * Used for display function - e.g. AJAX
 * When ajax changes the product variants, product variants with zero stock will not display add to cart button
 *
 */
public function canDisplayAddtocartStock($item, $stock)
{
    if (isset($item->id) && (int) $item->id > 0) {
        $item_addtocart = $this->params->get('item_addtocart', 0);
        $hide_add_to_cart_stock = $this->params->get('hide_add_to_cart_stock', 0);
        if ((int) $item_addtocart == 1 || (int) $item_addtocart == 4) {
            if ($hide_add_to_cart_stock == 1 && (int) $stock < 1) {
                return false;
            }
            return true;
        } else {
            return true;
        }
    }
    return false;
}