# eCommerce

Integrate Giftoin into your e-commerce platform to enhance customer experience and drive sales through strategic rewards.

**Post-Purchase Rewards**

Send a digital reward immediately after purchase completion:

```php
<?php
// After order confirmation
function sendPostPurchaseReward($customerEmail, $orderAmount, $orderNumber) {
  $curl = curl_init();
  
  $payload = [
    "contacts" => [$customerEmail],
    "title" => "Thank You for Your Purchase!",
    "description" => "Enjoy this special gift as a token of our appreciation.",
    "metadata" => [
      "orderNumber" => $orderNumber,
      "orderAmount" => $orderAmount
    ]
  ];
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.giftoin.org/api/v1/gcm/reseller/campaign/YOUR_CAMPAIGN_ID/order',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
    CURLOPT_HTTPHEADER => array(
      'x-gft_api_key: YOUR_API_KEY',
      'Content-Type: application/json'
    ),
  ));
  
  $response = curl_exec($curl);
  curl_close($curl);
  return json_decode($response, true);
}
?>
```

**Abandoned Cart Recovery**

Send a special offer to customers who abandoned their shopping carts:

1. Track cart abandonment in your e-commerce system
2. After 24 hours, send a gift with a discount coupon:

```javascript
// Scheduled job to process abandoned carts
async function processAbandonedCarts() {
  // Get carts abandoned 24 hours ago
  const abandonedCarts = await getAbandonedCarts(24);
  
  for (const cart of abandonedCarts) {
    try {
      const response = await fetch(`https://api.giftoin.org/api/v1/gcm/reseller/campaign/ABANDONED_CART_CAMPAIGN_ID/order`, {
        method: 'POST',
        headers: {
          'x-gft_api_key': 'YOUR_API_KEY',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          contacts: [cart.customerEmail],
          title: "Don't Miss Out!",
          description: "We saved your cart. Complete your purchase with this special discount.",
          metadata: {
            cartId: cart.id,
            cartValue: cart.totalValue
          }
        })
      });
      
      // Mark cart as processed
      await markCartProcessed(cart.id);
      
    } catch (error) {
      console.error(`Error processing abandoned cart ${cart.id}:`, error);
    }
  }
}
```

**Seasonal Promotions**

Create limited-time campaigns for holidays and special events:

1. Design themed digital collectibles or coupons
2. Set campaign start and end dates
3. Create urgency with limited quantities
4. Promote across email, social media, and your website
5. Track redemption rates compared to normal promotions

**Integration Tips**

* Connect Giftoin with your CRM to personalize rewards
* Use order data to segment customers and tailor rewards
* A/B test different reward types to optimize conversion
* Implement reward progress indicators at checkout
* Create exclusive membership tiers with special rewards


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.giftoin.org/resources/use-cases/ecommerce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
