My API Keys

Discount codes generator

If you want to use unique discount codes for your customers inside theMarketer platform, for Automation or Loyalty Program purposes, for example, you will need to create an endpoint in your ecommerce platform, which supports the generation of discount codes.

theMarketer currently supports 3 discount types: Fixed (type = 0), Percentage (type = 1) and Free Shipping (type = 2).

Optionally, discount rules in theMarketer platform can also have an expiration date. If the call we make to your API features an expiration date, it will need to be taken into account when creating the discount code.

Your endpoint for generating discount codes needs to respond with valid JSON with the following structure:

{
  "code" : "GENERATED_DISCOUNT_CODE"
}

PHP sample code for generating a discount code:

<?php

 $restApiKey = "REST_KEY";  \\ you will need to replace this with yout own REST API KEY
 
if (isset($_GET["key"]) && $_GET["key"] === $restApiKey && gettype($_GET["value"]) === "integer && gettype($_GET["type"]) === "integer") {
 
/* This is an code Example */
    $generateCode = DiscountCode::create(["value"  => $_GET["value],"type"   => $_GET["type"], "expiration"   => $_GET[‘expiration_date’]]);
		// "fixed value"=0 | "percentage"=1 | "free shipping"=2

/* Check if code was added to your database */
if ($generateCode) {
          $discountCode = array( "code" => $generateCode[‘code’]); //sample discount code: “ABCD124”
        }
     echo json_encode($discountCode);
 } else {
     echo json_encode(["status => "Incorrect REST API Key"]);
 }