|

Hook Before Coupon Code Is Validated
Posted 22 August 2014 - 01:46 AM #1
We have a need to be able to do some processing when a customer enters a coupon code into the cart or checkout coupon field. We want to actually insert a coupon into the promotion system based on the value they enter. I know that does not make sense, but we have a good reason for what we are doing. My problem is trying to find a hook function that allows me to insert a new promotion AND that promotion is usable based on the coupon code the customer entered.
So, for example, the customer enters a code that does not exist, say abc123. After they click the apply arrow I want to actually create a promotion on the fly for coupon code abc123. Then let the normal CS-Cart promotion validation process to see it and use it.
I have tried looking at many hooks mentioned in the documentation, like promotion_apply_pre, pre_promotion_validate, pre_promotion_check_coupon and promotion_check_coupon, but it seems that for all of these by the time the CS-Cart promotion validation process kicks in, it is working off a list of promotions from the database that were loaded BEFORE I could insert my special promotion.
I came across update_cart_by_data_post which I felt might be executed prior to loading the promotions from the database, but the hook never seems to be called, so I cannot confirm it works or not.
Can someone please guide me in the right direction as to which hook to use to accomplish what I am needing to do?
I am working with version 4.1.3.
So, for example, the customer enters a code that does not exist, say abc123. After they click the apply arrow I want to actually create a promotion on the fly for coupon code abc123. Then let the normal CS-Cart promotion validation process to see it and use it.
I have tried looking at many hooks mentioned in the documentation, like promotion_apply_pre, pre_promotion_validate, pre_promotion_check_coupon and promotion_check_coupon, but it seems that for all of these by the time the CS-Cart promotion validation process kicks in, it is working off a list of promotions from the database that were loaded BEFORE I could insert my special promotion.
I came across update_cart_by_data_post which I felt might be executed prior to loading the promotions from the database, but the hook never seems to be called, so I cannot confirm it works or not.
Can someone please guide me in the right direction as to which hook to use to accomplish what I am needing to do?
I am working with version 4.1.3.
Posted 22 August 2014 - 10:57 PM #2
app/addons/my_changes/controllers/frontend/checkout.pre.php
Add code like
Add code like
if( !defined('BOOTSTRAP') ) die('Access denied'); switch($mode) { case 'apply_coupon': $this_cert =& $_REQUEST['coupon_code']; // put your code logic here break; } return array(CONTROLLER_STATUS_OK);
EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.
Posted 25 August 2014 - 04:49 AM #4
You're welcome.
EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.