Thread: Coupon code URL

Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Location
    Arvada, Colorado
    Posts
    2
    Plugin Contributions
    0

    xhtml problem Coupon code URL

    I've seen this question posed, but I didn't see an answer. What I want to do is link our banner (.jpg image) on a site with a url that gives the customer a % off if they visit our site through that link. Is this possible and what would the coding be?
    Thanks,
    Ryan @ HardNutrition

  2. #2
    Join Date
    Mar 2006
    Posts
    250
    Plugin Contributions
    0

    Default Re: Coupon code URL

    Sorry for the delayed response. I've been working on this over the last couple of weeks. There's been a bit of discussion on this topic recently so I thought I'd post my solution. Please read the deficiencies before you give this a go.

    Based on Kevin's hints in:
    http://www.zen-cart.com/forum/showthread.php?t=42386

    I've come up with a solution to this problem. Before I give you the code I'll outline the method and note the deficiencies.

    Method:
    In index.php, check for a visitor_code in the URL. If present, sanitize and sessionalize it.

    In ot_coupon, instead of validating/sessionalizing a form submitted coupon code, validate/sessionalize the visitor_code. Then set visitor_code to null.

    Deficiencies: This method has some major deficiencies. As it stands, there's no validation of the coupon code when the visitor arrives on your site. There's not even acknowledgment of the coupon until they get to checkout. So, if a visitor follows an outside link that promises them a discount, they will be confused until checkout_payment and/or angry if the coupon is invalid.

    My solution: Outside links point to pages in my store with "Click Here to Begin Shopping Using This Coupon" links. This way I can explain the coupon details, let them know it won't show up until payment, and I can make sure that only valid coupons are provided.

    Deficiency: For some reason the user is notified through the message stack twice that their coupon has been added. Once during payment and once during confirmation. My attempts to show this only during checkout_payment sent the user to checkout_payment a second time.

    My solution: I settled on eliminating the message and applying <strong> to the coupon reporting in order total.

    Deficiency: My method does not allow for submitting coupons via form during checkout_payment.

    My solution: I removed the discount coupon field from checkout_payment. This was a feature for me, my entire goal was to remove coupon submission from checkout.

    Code: Solution implemented in 1.3.7, code may or may not apply to other versions.

    From /store/index.php, around line 101
    Code:
    <?php
    /**
     * Load general code run before page closes
     */
    ?>
    Becomes:
    Code:
    <?php
    /**
     * Load general code run before page closes
     */
    if (!empty($_GET['visitor_code']))
        $_SESSION['visitor_code'] = trim(htmlspecialchars($_GET['visitor_code']));
    ?>
    From /store/includes/templates/yourtemplate/templates/tpl_checkout_payment_default.tpl, around line 80:
    Code:
    <fieldset>
    <legend><?php echo $selection[$i]['module']; ?></legend>
    <?php echo $selection[$i]['redeem_instructions']; ?>
    <div class="gvBal larger"><?php echo $selection[$i]['checkbox']; ?></div>
    <label class="inputLabel"<?php echo ($selection[$i]['fields'][$j]['tag']) ? ' for="'.$selection[$i]['fields'][$j]['tag'].'"': ''; ?>><?php echo $selection[$i]['fields'][$j]['title']; ?></label>
    <?php echo $selection[$i]['fields'][$j]['field']; ?>
    </fieldset>
    Becomes:
    Code:
    <?php if($selection[$i]['module']!=MODULE_ORDER_TOTAL_COUPON_TITLE) {?><fieldset>
    <legend><?php echo $selection[$i]['module']; ?></legend>
    <?php echo $selection[$i]['redeem_instructions']; ?>
    <div class="gvBal larger"><?php echo $selection[$i]['checkbox']; ?></div>
    <label class="inputLabel"<?php echo ($selection[$i]['fields'][$j]['tag']) ? ' for="'.$selection[$i]['fields'][$j]['tag'].'"': ''; ?>><?php echo $selection[$i]['fields'][$j]['title']; ?></label>
    <?php echo $selection[$i]['fields'][$j]['field']; ?>
    </fieldset><?php } ?>
    Finally: /store/includes/modules/order_total/ot_coupon.php
    Code:
    line 54: $this->output[] = array('title' => $this->title . ': ' . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $this->coupon_code . '</a> :',
    
    Becomes:       $this->output[] = array('title' => '<strong>' . $this->title . ': ' . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $this->coupon_code . '</a></strong> :',
    
    Lines 220-221:
    if ($_POST['submit_redeem_coupon_x'] && !$_POST['gv_redeem_code']) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEST_NO_REDEEM_CODE), 'SSL', true, false));
          $messageStack->add_session('checkout', TEXT_VALID_COUPON,'success');
    
    Become:
    //      if ($_POST['submit_redeem_coupon_x'] && !$_POST['gv_redeem_code']) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEST_NO_REDEEM_CODE), 'SSL', true, false));
    //	$messageStack->add_session('checkout', TEXT_VALID_COUPON, 'success');
    	$_SESSION['visitor_code'] = NULL;
    
    Lines 144-209:
    Replace every instance of: $_POST['dc_redeem_code']
    with: $_SESSION['visitor_code']
    There's probably a cleaner and easier way to remove the Discount Coupon field.

    If anyone sees a violation of proper practices, please let me know.

    If anyone tries this and it doesn't work, let me know. I've done other modifications to the files above, and though I think I've isolated the coupon solution I may have gotten something else mixed in.

    Hope this helps,
    Joe
    Now J_Schilz
    Integrated Checkout Without Account
    (wiki w/pics, demo, download)

  3. #3
    Join Date
    Nov 2007
    Location
    North East United Kingdom
    Posts
    25
    Plugin Contributions
    0

    Default Re: Coupon code URL

    Hi Ryan,
    Could youplease let me know if you have managed to get this sorted. I'm looking to do exactly the same and don't seem to be able to do it with the solutions posted so far.
    Many thanks
    Ben

 

 

Similar Threads

  1. Redeeming coupon code from URL?
    By Cindy2010 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 13
    Last Post: 2 Sep 2013, 03:58 AM
  2. how can I code in a default coupon code into checkout page redeem, then auto-refresh?
    By lankeeyankee in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 29 Nov 2008, 04:56 AM
  3. Embedding coupon code in URL?
    By thewolf in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 2
    Last Post: 13 Jun 2008, 09:58 PM
  4. Coupon Code in URL
    By kevinhankens in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 20
    Last Post: 6 Oct 2007, 07:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg