close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Web development tutorial

Static eCart coupon link

Tutorial created by Kate Ford

Categories: Data Bridge, eCart, Dreamweaver, PHP

rating

In the third tutorial of the eCart coupon series, you will learn how to offer discounts on your products by placing links on web pages, emails, and newsletters. The link will lead customers directly to your website, for example, a product detail page. Once the product is added to your shopping cart, the discount will be automatically applied.

You'll find a linked index including an overview of each tutorial belonging to the eCart coupon series at the bottom of this page.

arrow downWhat do you need to start?

  1. Dreamweaver CS4 or higher.
  2. eCart 5 or higher installed and activated in Dreamweaver.
  3. Site defined in Dreamweaver. For assistance, view these tutorials: Define a dynamic site in CS4 or Define a dynamic site in CS5+.
  4. Product and admin pages built with DataAssist. For more assistance, view tutorials: Create a product catalog I and Create a product catalog II.
  5. PHP page with an eCart shopping cart. If you do not have one, view these tutorials to create the eCart object, add-to-cart button, and responsive shopping cart.

arrow downCoupon link overview

eCart allows you to offer discounts on your products via links, which you can place on webpages, in emails or in advertisements. In this 3-step tutorial, we demonstrate how someone can receive a 20% discount by clicking a link in an email. In addition, coupon links can be placed on your catalog pages, home page, web pages other than your own, and marketing newsletters. Another idea is to print the link in offline promotional material, for example, business cards and brochures.

In many cases, the preferable coupon from a marketing standpoint is a link. When customers click the link, they are led directly to your website where they can select a discounted product and add it to the shopping cart. When the cart page opens, the discount is automatically applied to the product. This eliminates the distraction of hunting online for codes and helps retain customers on your site, potentially increasing sales.

Now for an overview of the 4-step process to creating coupon links:

  1. Designate the product in your product catalog to discount. In this tutorial, we add a rugged track and trail athletic shoe named "Los Angeles".

  2. Create the coupon link to be placed on an email, newsletter, or web page. In this tutorial, we added the link to an email.

  3. Add the snippet of code containing the session variable to a page on your website. In this tutorial, we chose the products detail page but the code can also be placed on multiple pages.

  4. Create the discount rule in the eCart object to apply the coupon to your product.

arrow downThe product

In this tutorial, we have chosen a product from our product catalog that we wish to sell at a discount.

  1. The product is the Los Angeles, a rugged track and trail athletic shoe.


  2. The 20% discount will be applied to the Los Angeles when customers click a coupon link.

arrow downThe coupon link

There are four parts to a creating a static coupon link. As an example, we will create the link based on the local testing site in this tutorial.

  1. The link begins with the website URL. In this case, we are using our localhost test server, but typically this will be your domain, such as www.yourwebsite.com/:
    http://localhost/ecommerce_test/



  2. Next, we add the page that will accept the incoming link:
    products_detail.php



  3. We follow with the Product ID of the track and trail shoe that we have chosen to discount: where ProductID is the name of the column in the database that identifies the product and 2 is the ID of the product being discounted‏:
    ?ProductID=2



  4. Then we append CID (which we will use as our session variable in the next section) and TrackandTrail (which we will use for our discount rule name):
    &CID=TrackandTrail


  5. This is the finished result:
    http://localhost/ecommerce_test/products_detail.php?ProductID=2&CID=TrackandTrail
    .
  6. Now add the link to an email.
    The link will not be functional until you have fully completed the steps in this tutorial.

arrow downThe session variable

Now we will hand code a session variable called PromoCode to the product detail page. You can also add the session variable to any page that you created a link for in the Create link section. However, do not link to any any page that contains a redirect.

If you have followed the first two tutorials of the eCart coupon series, you will recall that they demonstrated how to apply coupon codes. The difference with coupon links is that, instead of getting the coupon ID from the posted form on the shopping cart, you are getting it from a URL.
  1. In Dreamweaver, open your products detail page in split code view and place your cursor after this line of code:
    <?php
    $eCart1->GetContent();
    ?>


  2. Copy (Ctrl or Cmd + C) the following snippet of code:
    <?php
    @session_start();
    if((((isset($_GET["CID"]))?$_GET["CID"]:"") != "")) {
    $_SESSION["PromoCode"] = "".((isset($_GET["CID"]))?$_GET["CID"]:"") ."";
    }
    ?>

    "CID" is the coupon ID. PromoCode is the name of the link.

  3. Paste (Ctrl or Cmd + V) the snippet of code containing the session variable into your products detail page.

arrow downThe discount rule

In the last step, you'll create a discount rule in the eCart object to apply the coupon link to a specific product. in this tutorial, the discount rule will be applied to a rugged track and trail athletic shoe.

  1. In Dreamweaver, go to WebAssist > eCart > eCart Object.

  2. Make sure the correct cart is chosen. In this tutorial, the cart is eCart1.

  3. Click the pencil icon.


  4. When the eCart object window opens, you will be in the General tab and should see the correct cart name.

  5. Click the Discounts tab.


  6. In the Discounts tab, click the plus icon to add a promotion.


  7. When the eCart Merchandising Rule dialog box opens, enter 20% Discount on Track and Trail Shoe (or another name of your choosing) in the Name field.


  8. Click the plus button to set the triggers.


  9. The first condition to be added ensures that at least one item will be in the shopping cart before applying the discount.

  10. Select Total number of unique items in the cart from the Condition list.

  11. Choose the greater than symbol (>) and leave 0 in the value field.


  12. To add the second condition, click the plus button once again.

  13. Choose AND from the Separator list.

  14. Choose Based on session variable value from the Condition list.

  15. Enter PromoCode for the name of the session variable.

  16. Select the equals symbol (=).

  17. Enter TrackandTrail in the value field. (If you want to rename the value, don't forget to edit your link with the new value name.)


  18. Now you'll set the calculations for the discount you wish to offer.
    In this tutorial, we are setting the discount to 20%.

  19. Select Based on items with a specific value from the Calculation list.

  20. For Total of, choose TotalPrice.

  21. After where, choose ID.

  22. For value, choose 2, then times, and lastly, enter the percentage of the discount, 0.20.


  23. Click OK.
    The eCart Object can store multiple discounts. The other discounts you see listed were created during the other two coupon tutorials in this series. (See linked index at the bottoom of this page.)


  24. Click OK once more and Finish to close the eCart object window.

  25. Test your coupon code by clicking the link that you added to an email earlier in the coupon link section.


  26. The link in the email opens the products detail page where clicking the Add to Cart button will add the Los Angeles into the shopping cart.


  27. In the shopping cart, the 20% discount will be applied to the rugged track and trail athletic shoe, Los Angeles.

arrow downWhat's your next step?

Proceed to Database-driven eCart coupon I, the next tutorial in the eCart coupon series, to learn about dynamic coupons that apply a discount based on a specific dollar amount to the total products or individual items purchased on your website. (Coming soon.)

arrow downeCart coupon series

eCart coupon series: An overview of five in-depth tutorials that demonstrate how to create coupons to discount products offered for sale on your website.

Static eCart coupon code I: In the first tutorial of the coupon series, you will learn how to create a coupon on your website that allows customers to apply a discount to the total purchase by entering a code into a text field on the shopping cart.

Static eCart coupon code II: In the second tutorial of the coupon series, you will learn how to create a static coupon on your website that allows customers to apply a discount to specific items by entering a code into a text field on your shopping cart.

Static eCart coupon link: In the third tutorial of the eCart coupon series, you will learn how to offer discounts on your products by placing links on web pages, emails, and newsletters. The link will lead customers directly to your website, for example, a product detail page. Once the product is added to your shopping cart, the discount will be automatically applied.

Database-driven eCart coupon I: In the fourth tutorial of the eCart coupon series, you will learn how to create database-driven (dynamic) coupons that allow customers to apply a discount based on a specific dollar amount to a particular item or the total products they purchase on your website. (Coming soon.)

Database-driven eCart coupon II: In the fifth tutorial of the eCart coupon series, you will learn how to create database-driven (dynamic) coupons that allow customers to apply a discount based on a percentage to a particular item or the total products they purchase on your website. (Coming soon.)

arrow downReviews and comments

Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.

Sign in to add comments
rating

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.