Jump to content

How to limit a cart rule to the number of orders of the customer?


Recommended Posts

How do I limit a cart rule to the number of customer's orders?
In other words, how do I create a voucher code for customers who have no orders yet?

I am thinking like this:
1. create a module which adds a check mark to cart rule form with the title of "usable for first orders only"

2. find a hook in the code where the addition of cart rule to the cart happens

3. check the number of orders and validate if this cart rule can be applied or not

Do you have any ideas?

Edited by Ali Samie (see edit history)
Link to comment
Share on other sites

1 hour ago, Ali Samie said:

Do you have any ideas?

I think that a Client is easier gained if reoccourring customers receive a Benefit by being part of the club.
Happy clients make a shop popular. I believe it to be an error the commun way just concentrating on purely newcomers.

Link to comment
Share on other sites

1 hour ago, Nickz said:

I think that a Client is easier gained if reoccourring customers receive a Benefit by being part of the club.
Happy clients make a shop popular. I believe it to be an error the commun way just concentrating on purely newcomers.

Thanks for the answer but the issue is not to gain new customers. There is a different scenario. We work with some influencers in instagram and we want to use a voucher code for the new customers who come from this channel. This way we can measure the efficiency of the work.

Link to comment
Share on other sites

In the functional part it would be necessary to use the function to obtain information about the orders registered by the customer.

Order::getCustomerOrders($this->context->customer->id);

adding new field  type isBool in table cart_rule and in the class CartRule.php and also adding  the new parameter  in the function getCustomerCartRules of the class CartRule.php

 

 

  • Like 2
Link to comment
Share on other sites

3 minutes ago, ventura said:

In the functional part it would be necessary to use the function to obtain information about the orders registered by the customer.

Order::getCustomerOrders($this->context->customer->id);

adding the new parameter  in the function getCustomerCartRules of the class CartRule.php

 

 

Thanks for your answer.

I was thinking like this. To add the check mark in the default cart rule form with this hook action<AdminControllerClassName>FormModifier
But it was not working as the form was not initiated in the AdminCartRule controller at all.

Then I wanted to find a hook for the time that a cart rule is being added to the cart but failed to find one. Do you know which hooks I should use?

Link to comment
Share on other sites

For the operational part I think the best way would be to do it from 

controllers/admin/AdminOrdersController.php

admin/themes/default/template/controllers/cart_rules/informations.tpl

 

And review the integration of the field in

/src/Adapter/CartRule/QueryHandler/GetCartRuleForEditingHandler.php

/src/Adapter/Order/Refund/VoucherGenerator.php

  • Like 1
Link to comment
Share on other sites

49 minutes ago, Ali Samie said:

We work with some influencers in instagram and we want to use a voucher code for the new customers who come from this channel.

Well there is a module for thirtybees/prestashop which does that, kinda.
You can also configure Matomo to give out customlinks to influencer to measure their participation. 

  • Like 1
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...