Page 1 of 1

Perform specfic action in checkout depending on category

Posted: Mon Nov 08, 2010 8:07 pm
by timkirtley
Hi.

Couldn't really fit in a descriptive title, so here goes:


Basically, I would like to be able to run a specific bit of code upon order completion, depending on the product purchased, as the code is not applicable to all products..


Does something like that sound possible? Some sort of conditional statement according to whether a product is in a certain category?


Thanks in advance for any help.

Re: Perform specfic action in checkout depending on category

Posted: Tue Nov 09, 2010 9:32 am
by kedgetech
timkirtley wrote: Basically, I would like to be able to run a specific bit of code upon order completion, depending on the product purchased, as the code is not applicable to all products..
Does something like that sound possible? Some sort of conditional statement according to whether a product is in a certain category?
You can be able to update the product module to have a flag (checkbox) to run your piece of code. More in the lines of our module Per-product-fee (http://www.kedgegroup.com/store/OpenCar ... Fee_Module). Should not be that difficuilt i suppose. I believe you may have more control on the product level compared to category.

Re: Perform specfic action in checkout depending on category

Posted: Wed Nov 10, 2010 7:19 pm
by timkirtley
Hi,

Thanks for your reply.

How exactly would the approach you mention work? You would add a custom variable to the required products - how would the code that completes an order be able to pick up on that flag/variable?

Re: Perform specfic action in checkout depending on category

Posted: Thu Nov 11, 2010 6:17 pm
by kedgetech
timkirtley wrote:How exactly would the approach you mention work? You would add a custom variable to the required products - how would the code that completes an order be able to pick up on that flag/variable?
Not sure I understand your question. "How would the code that completes and order" - Are you saying your code completes the order not the opencart?

I would say based on the flag you have to run the code some where during the checkout process, you can get the variables from the cart. Care to mention whats the code you want to run ?

Re: Perform specfic action in checkout depending on category

Posted: Thu Nov 11, 2010 6:42 pm
by timkirtley
Okay sorry, to clarify:

No there's no special code completing the order, I mean the Opencart code that completes the order - adds it the db, sends confirmation emails, displays success message.


Basically, some products when purchased need to be automatically registered for a Warranty, some but not all products.

The code to register for a warranty, simply adds the details to a newsletter mailing list, its about 15 lines of php.

I need to be able to run this code when a successful order goes through for an applicable product.

Re: Perform specfic action in checkout depending on category

Posted: Fri Nov 12, 2010 6:13 am
by kedgetech
You should hunt down the code that triggers after the sucessful order and add the code there. You can check the products in the cart and based on condition that the flag we discussed exists manuplate the code to run or no-run

Hope that helps

Cheers.