Help with Free Shipping for VIP Module
Posted: Tue Apr 09, 2024 2:01 pm
Hi,
I'm trying to create a very simple shipping module that will allow VIP customers to select free shipping... I have got it working so that the option only shows if the customer has the vip_customer switch active on thier account, but If the customer selects the option and presses "continue checkout" it reloads the checkout_shipping.php page rather than going to checkout_payment.php....
Can anyone tell me what I have done wrong?
I'm trying to create a very simple shipping module that will allow VIP customers to select free shipping... I have got it working so that the option only shows if the customer has the vip_customer switch active on thier account, but If the customer selects the option and presses "continue checkout" it reloads the checkout_shipping.php page rather than going to checkout_payment.php....
Can anyone tell me what I have done wrong?
Code: Select all
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
class vip_free extends abstract_shipping_module {
const CONFIG_KEY_BASE = 'MODULE_SHIPPING_VIP_FREE_';
// class methods
public function update_status() {
$check_vip_cust_query = $GLOBALS['db']->query("SELECT customers_vip_customer FROM customers WHERE customers_id = '" . (int)$_SESSION['customer_id'] . "'");
$check_vip_cust = $check_vip_cust_query->fetch_assoc();
// disable the module if customer is not a VIP
if ($check_vip_cust['customers_vip_customer'] !='1') {
$this->enabled = false;
}
return;
}
public function quote($method = '') {
global $order;
$this->quotes = [
'id' => $this->code,
'module' => MODULE_SHIPPING_VIP_FREE_TEXT_TITLE,
'methods' => [[
'id' => $this->code,
'title' => MODULE_SHIPPING_VIP_FREE_TEXT_WAY,
'cost' => '0',
]],
];
$this->quote_common();
return $this->quotes;
}
protected function get_parameters() {
return [
$this->config_key_base . 'STATUS' => [
'title' => 'Enable VIP Free Shipping',
'value' => 'True',
'desc' => 'Do you want to offer Free shipping for VIP Customers?',
'set_func' => "Config::select_one(['True', 'False'], ",
],
$this->config_key_base . 'SORT_ORDER' => [
'title' => 'Sort Order',
'value' => '0',
'desc' => 'Sort order of display.',
],
];
}
}