1. Go to this page and download the library: Download mathewberry/cart library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Example Data
$id = 24;
$code = "MB25OFF"; // 25% Off
$discount = 25.00; // 25%
$is_fixed = false; // Percentage
$display = '-' . number_format($discount, 2) . '%'; // How it should be displayed to the customer.
Cart::voucher($id, $code, $discount, $is_fixed, $display);
Cart::voucher();
[
"id" => $voucher_id, // Voucher id
"code" => $voucher_code, // Voucher code
"display" => $voucher_display, // Customer friendly, e.g: "25%"
"is_fixed" => $voucher_fixed, // Percentage voucher or fixed price
"discount" => $voucher_discount_value // Value of voucher
]