theme updates
This commit is contained in:
@@ -124,6 +124,9 @@ foreach ($availableAddOns as &$addOn) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$addOnOutput = site()->view("add_on_chooser", [
|
||||
"add-ons" => $availableAddOns,
|
||||
"add-ons-onetime" => $AddOnsOnetime,
|
||||
@@ -133,12 +136,28 @@ $addOnOutput = site()->view("add_on_chooser", [
|
||||
// this function is defined in functions.php as we use it in a few places
|
||||
$cartSummary = generateCartSummary();
|
||||
|
||||
// Check if the form was submitted
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['apply_coupon'])) {
|
||||
$coupon_code = isset($_POST['coupon_code']) ? wc_format_coupon_code($_POST['coupon_code']) : '';
|
||||
|
||||
if (!empty($coupon_code)) {
|
||||
WC()->cart->apply_coupon($coupon_code);
|
||||
wc_add_notice(__('Coupon applied successfully.', 'woocommerce'));
|
||||
// Redirect to prevent form resubmission on page reload
|
||||
wp_redirect(wc_get_cart_url());
|
||||
exit;
|
||||
} else {
|
||||
wc_add_notice(__('Please enter a valid coupon code.', 'woocommerce'), 'error');
|
||||
}
|
||||
}
|
||||
echo site()->view("cart", [
|
||||
"installation" => $installationOutput,
|
||||
"addOns" => $addOnOutput,
|
||||
"content" => $cartSummary,
|
||||
"couponSummary" => $couponSummary,
|
||||
]);
|
||||
|
||||
// take it away from here!
|
||||
|
||||
|
||||
get_footer();
|
||||
|
||||
Reference in New Issue
Block a user