Gift Certificates: Coupons are not generated automatically


  • Default avatar
    telefontastatur    
     2 years ago
    0

    Hello,

    a few days ago, we purchased an "AwoCoupon for PrestaShop" license. We would like to use it for gift certificates. I installed the module and it seems that everything is fine: There is a shop product, a coupon template and a gift certificate product that is linked to the shop product. There are also several Email templates. But when an order (that contains the shop product) is placed and the right order status (set in Configuration > Gift Certificate Products) is active, nothing happens. There is no generated coupon and no Email. I checked everything twice and even followed the tutorial (https://awodev.com/blog/sell-gift-certificates-online-your-virtuemart-store). I can generate a coupon via Tools > Send a voucher. Having done this, I can find a new coupon in the list and there is also an Email (containing text and an image). But, of course, this should work automatically. So where is the problem? Why doesn't AwoCoupon create the coupon? Is there something that I forgot when configuring the module?


    Thanks a lot in advance for helping me!

  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    It may be the required prestahsop hook is not installed.  In order to generate the gift certificate on specified order status, the "actionOrderStatusPostUpdate" hook needs to be registered for AwoCoupon.

    You can have awocoupon reinstall all the required hooks by:

    1. in file /modules/awocoupon.php, around line 97 uncomment:
    <?php
            
    //$installer = $this->helper->new_class( 'AwoCoupon_Helper_Update' ); $installer->install_hooks();
    ?>

    Like this:
    <?php
            $installer 
    $this->helper->new_class'AwoCoupon_Helper_Update' ); $installer->install_hooks();
    ?>

    In /modules/awocoupon/helper/class-awocoupon-helper-update.php round line 215, change
    <?php
        
    private function install_hooks() {
    ?>

    To
    <?php
        
    public function install_hooks() {
    ?>

    Then in the backend, refresh the AwoCoupon dashboard.
  • Default avatar
    telefontastatur    
     2 years ago
    0

    Hello,

    thanks for your reply! I tried to do it the way you told me:

    1) There is no line 97 with that code. Line 97 belongs to the function init(). I found $installer = $this->helper->new_class( 'AwoCoupon_Helper_Update' ) nearly at the end of the file (line 431, function install()) but there was no $installer->install_hooks(). That’s why I didn’t change anything in that file.

    2) I found that function and changed “private” to “public”.

    As I wasn’t sure whether this would be enough I uninstalled the module and reinstalled it. Then I opened the hook list to see whether the hooks were registered but there was no hook registered for AwoCoupon. Is that correct? So, I opened the “Add module” page and registered the “actionOrderStatusPostUpdate” hook manually for AwoCoupon:


    Was that necessary? I only registered that single hook, not all of them in the list.

    Anyway, it works! When I change the order status, a coupon is generated and an email is sent to the purchaser. I can find that order in AwoCoupon’s history of uses as well. That’s great!

    Maybe, you could tell me what to do with the other hooks. Do I have to register them manually? Was it necessary to register the “actionOrderStatusPostUpdate” hook manually?

  • Your avatar
    seyi    
     2 years ago
    0

    Yes, that process was kind of complicated.  Will make it a 1 click process on the next update.

    Glad you got it working.  Should not have had to manually register it, should have been registered automatically.  The other various hooks are used for other functions.  For example, there is one hook that is needed for automatic coupons to work.  If you add a coupon to the automatic coupon list, does it work in the front end without entering the coupon code?  If so, then you already have the hooks installed.

  • Default avatar
    telefontastatur    
     a year ago
    0

    I tried it—and it didn’t work. Then I registered the remaining hooks manually—and suddenly, it worked!


    As I said in my last reply, I only changed the function install_hooks() from “private” to “public” because I couldn’t find $installer->install_hooks() in awocoupon.php (I am using the most recent version). Maybe, you could check this when releasing the next update.