Jump to content

Edit History

PawelTR

PawelTR

Hello,
I try write module which limit cart. I mean limit:
- max 10 pieces of single product in one order
- max 1 pieces of single product which in database have flag "deficit"

This things i have check when user adding product to cart. When user adding product with quantity >= 10 or deficyt product >1 then i need show message with information.

I have code:

 public function hookActionBeforeCartUpdateQty($params)
    {
        $product = $params['product'];
        $quantity = $params['quantity'];

        echo '<pre>';
        echo 'Product name: ' . $product->name . '<br />';
        echo 'Product id: ' . $product->id . '<br />';
        echo 'Quantity' .$quantity;
        echo '</pre>';

        if($quantity >=10) {
            return false;
        }

    }

but not working, when i add product with qunantity >=10, product is added successfully, this is my first problem.

My second problem is that I want to write a module that will develop a product that will have flags:
- 1 item per day for 1 user
- 1 item per week for 1 user
- 1 item per month for 1 user

And I would like to check it when adding it to the cart, but it can't be done because I can't check if a person who has not logged in has already bought the product, he must be logged in, so I am looking for ideas on how to solve it.

PawelTR

PawelTR

Hello,
I try write module which limit cart. I mean limit:
- max 10 pieces of single product in one order
- max 1 pieces of single product which in database have flag "deficit"

This things i have check when user adding product to cart. When user adding product with quantity >= 10 or deficyt product >1 then i need show message with information.

I have code:

 public function hookActionBeforeCartUpdateQty($params)
    {
        $product = $params['product'];
        $quantity = $params['quantity'];

        echo '<pre>';
        echo 'Product name: ' . $product->name . '<br />';
        echo 'Product id: ' . $product->id . '<br />';
        echo 'Quantity' .$quantity;
        echo '</pre>';

        if($quantity >=10) {
            return false;
        }

    }

but not working, when i add product with qunantity >=10, product is added successfully, this is my first problem.

My second problem is that I want to write a module that will develop a product that will have flags:
- 1 item per day for 1 user
- 1 item per week for 1 user
- 1 item per month for 1 user

And I would like to check it when adding it to the cart, but it can't be done because I can't check if a person who has not logged in has already bought the product, he must be logged in, so I am looking for ideas on how to solve it.

×
×
  • Create New...