Help with Free Shipping for VIP Module

Open to all! Ask other shopowners for help.
Post Reply
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Help with Free Shipping for VIP Module

Post by Portman »

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?

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.',
        ],
      ];
    }

  }


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Help with Free Shipping for VIP Module

Post by Kofod95 »

Might not be that, but as far as I remember underscores are not allowed in class names for shipping modules. Try removing underscore in class and file name

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: Help with Free Shipping for VIP Module

Post by Portman »

That was it, thankyou very much
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Help with Free Shipping for VIP Module

Post by Kofod95 »

Good to hear!
I found the explanation:
The way that [Phoenix] handles the shipping is to join the module and method names with an underscore. E.g. free_free or table_table. With the idea that sometimes the method might not have the same name as the module. E.g. fedex_groundslow, fedex_nextdayair. So if the module name has an underscore, e.g. my_table, then you get something like my_table_my_table and it thinks the module is my and the method is either table_my_table or table.
viewtopic.php?p=2721#p2721

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply