CMXX - Webhooks and giftcards

This commit is contained in:
“VeLiTi”
2025-02-19 12:11:44 +01:00
parent d85923c299
commit 0e9d133ff9
10 changed files with 358 additions and 335 deletions

View File

@@ -40,30 +40,33 @@ if ((isset($_POST['update']) || isset($_POST['checkout'])) && isset($_SESSION['c
}
// Check if accessoiries are added
if (isset($_POST['accessoiries'])){
$options = '';
$quantity = 1;
$cart_product = &get_cart_product($_POST['add_product_id'], $options);
if ($cart_product) {
// Product exists in cart, update the quanity
$cart_product['quantity'] += $quantity;
} else {
// Product is not in cart, add it
$_SESSION['cart'][] = [
'id' => $_POST['add_product_id'],
'quantity' => $quantity,
'options' => $options,
'options_price' => $_POST['add_product_price'],
'options_weight' => $_POST['add_product_weight'],
'shipping_price' => 0.00
];
if (isset($_POST['product'])) {
//VALIDATE THE INPUT FOR THE SHOPPING CART
$payload = json_encode($_POST['product'], JSON_UNESCAPED_UNICODE);
$product_to_cart = ioAPIv2('/v2/shopping_cart/',$payload,$clientsecret);
$product_to_cart = json_decode($product_to_cart,true);
// Check if the product exists (array is not empty)
if ($product_to_cart['quantity'] > 0) {
// Product exists in database, now we can create/update the session variable for the cart
if (!isset($_SESSION['cart'])) {
// Shopping cart session variable doesnt exist, create it
$_SESSION['cart'] = [];
}
$cart_product = &get_cart_product($product_to_cart['id'], $product_to_cart['options']);
if ($cart_product) {
// Product exists in cart, update the quanity
$cart_product['quantity'] += $quantity;
} else {
// Product is not in cart, add it
$_SESSION['cart'][] = $product_to_cart;
}
}
// Prevent form resubmission...
header('Location: ' . url('index.php?page=cart'));
exit;
}
// Check if samples are added
if (isset($_POST['samples'])){
$options = $h2_cart_sample_product;
$quantity = 1;
@@ -184,10 +187,10 @@ $view .= '</tbody>
if (!empty($products_in_cart) && !empty(category_id_checkout_suggestions)){
$view .= getAccessoiries($clientsecret,category_id_checkout_suggestions);
}
// SAMPLES
/* SAMPLES
if (!empty($products_in_cart) && !empty(category_id_checkout_samples)){
$view .= getSamples($clientsecret,category_id_checkout_samples);
}
}*/
$view .= '
<div class="total">
<span class="text">'.$total_subtotal.'</span>