coupon-code prefilled in coupon code field until customer has used it.


  • Your avatar
    seyi    
     6 years ago
    0

    Hi Seyi,

    Thanks for this wonderful component.
    I'm using it as "coupon upon registration". For this, I've set the number of uses to "1" and send the code to the customer in the registration confirmation email. Additionally, I'm displaying the code within Virtuemart's "Registration Complete!" message.

    However, there are still user which don't recognize the coupon code and process their order without it. Since I'm attracting new customers to my shop with this coupon, I always have some customer compaining.

    Since I want to make my shop as userfriendly as possible, I want to ask you whether the following solution would be possible:

    The coupon code should be automatically filled in the coupon code field until the customer has used his coupon code.

    What do you think?

    Best regards,
    solala
  • Your avatar
    seyi    
     6 years ago
    0

    I am a little confused. This component does not work with registration. Are you trying to use awocoupon in conjuction with another component? The is probably the reason the coupon codes are not being recognized, because they were created by another component and not awocoupon.

    To answer your question about automatically filling the coupon code field, I dont think that would be possible in reality. Because you could create many coupons that a user can use, and which would you actually populate?
  • Default avatar
    solala    
     6 years ago
    0

    It is possible to grant customers a coupon at registration.
    It's just a matter of workflow.

    Maybe I was not very clear with my first description.

    My setup:
    - AWO does not work in conjunction with another component for this job
    - Right now, I only have one coupon code, function type "coupon", number of uses "1"
    - I have hard-coded the coupon code in the "registration confirmation email", the customer gets after his registration

    Result:
    - When the customer registers, he automatically gets emailed the coupon code.
    - In my case, he only can use it once.

    It's maybe not he ideal solution, but it works perfect!


    Prefilling:
    In \administrator\components\com_virtuemart\languages\common\.php, there is the language variable called 'REG_COMPLETE'. This message is being displayed after registration.
    I just have to find how it is being displayed and than i can use this mechanism for a pre-filled input field of the coupon. But i don't have any glue so far how this mechanism works...
  • Your avatar
    seyi    
     6 years ago
    0

    Ah ha, I think I see what you are trying to do now. I think there are 2 things you will need to do.

    1) verify the user has just registered. I dont think virtuemart sets anything. So within the class file that registers a user, probably ps_user.php, create a session variable after confirming a user has registered. Something like
    $_SESSION['user_just_registered'] = 1;

    2) then within the couponfield file check for the variable, and if it exists, populate the coupon_code field with the coupon code. Assuming you are using the default theme in virtuemart, then this is the couponfield file:
    www/components/com_virtuemart/themes/default/templates/common/couponField.tpl.php
  • Default avatar
    solala    
     6 years ago
    0

    i knew i was asking the right one!

    thanks for pushing me towards the right direction, you've saved my evening. gonna have a beer on your behalf.

    here is my solution:
    ============================================
    administrator/components/com_virtuemart/classes/ps_shopper.php:
    find about line 473:
    vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

    add directly above:
    $_SESSION['user_just_registered'] = 1;
    ============================================
    /components/com_virtuemart/themes/default/templates/common/couponField.tpl.php:
    find about line 37:
    < input type="text" name="coupon_code" id="coupon_code" width="10" maxlength="30" class="inputbox" />
    (skip the space between "<" and "input")

    replace it with
    <?php
    if (isset($_SESSION['user_just_registered'])){
        echo 
    '';
    }else{
        echo 
    '';
    }
    ?>

    ============================================
    of course, "coupon_code_upon_registration" has to be your own coupon code.
  • Default avatar
    dirk23    
     6 years ago
    0

    Hello
    looks a great idea to provide customer with coupon after registering !
    could you guide me how to set it up please ? Your help highly appreciated as i am not very familiar with all this :)

    Regards from belgium
    Dirk
  • Your avatar
    seyi    
     6 years ago
    0

    what exactly are you having troubles with?

    You can create a coupon and set it to 1 use per customer. This coupon will require the user to be logged in to use it. Then you can hard code the coupon code into the email that is sent out to the customer.

    The user above used this file:

    www\administrator\components\com_virtuemart\languages\common\[english].php

    and just added the code somewhere in the REG_COMPLETE variable.


    If you want more control of where you place the coupon code, you can edit this file instead:

    www/components/com_virtuemart/themes/[default]/templates/order_emails/comfirmation_email.tmp.php

    You can change out [default] for the theme you are actually using.
  • Default avatar
    dirk23    
     6 years ago
    0

    Hi
    for you it is certainly very easy to understand... but i don't :(

    How do you : added the code somewhere in the REG_COMPLETE variable ?


    Otherwise, i can find, and edit this file : www/components/com_virtuemart/themes/[default]/templates/order_emails/comfirmation_email.tmp.php
    but i not know what i must do , amend or change inside it :)

    DIrk


  • Your avatar
    seyi    
     6 years ago
    0

    I see. It would probably be easier to edit the reg_complete variable within the language file.

    By default the reg_complete says this (in english):
    'REG_COMPLETE' => '<div class="componentheading">Registration Complete!</div>',


    For example you could change it to say this:
    'REG_COMPLETE' => '<div class="componentheading">Registration Complete!</div>

                    <div>Get 10% off on your first order when use the coupon code <b>1TIME</b></div>',


    In this case 1TIME is the coupon you created.
  • Default avatar
    dirk23    
     6 years ago
    0

    And where can i find this 'REG_COMPLETE' please ?
    Is this a file ?

    thanks
    dirk
  • Your avatar
    seyi    
     6 years ago
    0

    No, that is a variable that is located inside a file. As long as you have access to the files for you website, you can find it here:
    www/administrator/components/com_virtuemart/languages/common/[english].php

    where www is the root of your website and [english] is the language file you are using. in my case it is english.php.