πŸŽ‰ Announcing Cart Package Coupon Feature!

realrashid

Rashid Ali

Posted on August 11, 2024

πŸŽ‰ Announcing Cart Package Coupon Feature!

I am thrilled to unveil an exciting new feature for the Cart package: Coupons! This update brings enhanced flexibility and functionality to your Laravel-based e-commerce solutions, making it easier than ever to offer discounts and promotions to your customers.

What’s New?

With the new Coupon feature, you can now:

  • Apply Discounts: Add both percentage-based and fixed amount coupons to your cart.
  • Create Custom Coupons: Develop your own coupon classes to suit your unique business needs.
  • Manage Coupons Efficiently: Apply, remove, and get details of applied coupons with ease.

Key Features

1. Apply Coupons with Ease

Integrate discount promotions effortlessly with our new methods. You can apply a coupon to your cart using a simple method call:

use RealRashid\Cart\Facades\Cart;
use App\Coupons\PercentageCoupon;

// Create a percentage-based coupon
$percentageCoupon = new PercentageCoupon('PERCENT20', 20, '2024-12-31');

// Apply it to the cart
Cart::instance('cart')->applyCoupon($percentageCoupon);
Enter fullscreen mode Exit fullscreen mode

2. Custom Coupon Classes

Design and implement custom coupon classes by implementing the Coupon interface. Here’s a sample of a fixed amount coupon:

<?php

namespace App\Coupons;

use RealRashid\Cart\Coupon\Coupon as CouponContract;
use App\Models\Coupon as CouponModel;

class FixedAmountCoupon implements CouponContract
{
    protected $coupon;

    public function __construct(CouponModel $coupon)
    {
        $this->coupon = $coupon;
    }

    public function getCode(): string
    {
        return $this->coupon->code;
    }

    public function isValid(): bool
    {
        return $this->coupon->isValid();
    }

    public function getDiscountType(): string
    {
        return 'fixed_amount';
    }

    public function getExpiryDate(): string
    {
        return $this->coupon->expiry_date;
    }

    public function getDiscountAmount(): float
    {
        return $this->coupon->amount;
    }
}
Enter fullscreen mode Exit fullscreen mode

3. Manage Applied Coupons

Easily manage your applied coupons with new methods to apply, remove, and retrieve details about your coupons:

  • Apply Coupon: Cart::applyCoupon($coupon);
  • Remove Coupon: Cart::removeCoupon();
  • Get Coupon Details: Cart::getAppliedCouponDetails();

How to Get Started

Ready to add discounts to your cart? Follow the updated usage documentation for detailed instructions on how to leverage the new Coupon feature.

Why This Matters

Coupons are a powerful tool for increasing sales and enhancing customer satisfaction. By integrating this feature into the Cart package, we aim to make it easier for you to run effective promotions and manage discounts, ultimately driving more value to your customers and business.

Join the Conversation

I would love to hear your feedback! Share your thoughts and experiences with the new Coupon feature by joining our community forums or connecting with us on social media.

Check It Out

Explore the Cart package and contribute to its development on our GitHub repository.


Thank you for your continued support. Stay tuned for more exciting updates and features!

Happy discounting! πŸŽ‰

πŸ’– πŸ’ͺ πŸ™… 🚩
realrashid
Rashid Ali

Posted on August 11, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related