Zen Cart Logo
Forums / General Questions / COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

Views: 7,698

Results 1 to 11 of 11
9 Jan 2013, 2:04 PM
#1
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

EDIT It's not the COD module (this does work) it's the accountholder module

We have a customised version of the "accountholder" payment module installed on our site at https://www.silkblooms.co.uk. We use a butchered version of this module to allow our customers to checkout on a payment plan.

The only issue we have with this at the moment is making it work when the product is set with these parameters:

Product is Virtual: - Yes, Skip Shipping Address
Always Free Shipping: - Yes, Always Free Shipping

Is there a way to make a payment module work when these product settings are used?

10 Jan 2013, 2:07 PM
#2
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

limelites:

EDIT It's not the COD module (this does work) it's the accountholder module

We have a customised version of the "accountholder" payment module installed on our site at https://www.silkblooms.co.uk. We use a butchered version of this module to allow our customers to checkout on a payment plan.

The only issue we have with this at the moment is making it work when the product is set with these parameters:

Product is Virtual: - Yes, Skip Shipping Address
Always Free Shipping: - Yes, Always Free Shipping

Is there a way to make a payment module work when these product settings are used?

Actually, COD and ACCOUNTHOLDER are the same module. I think accountholder is a butchered version of COD. however, COD comes up as an option at the checkout confirmation page but accountholder doesn't. Does anyone know why?

10 Jan 2013, 2:49 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

I am not familar with this accountholder ... could you post the file in the:
/includes/modules/payment

that you are using?

10 Jan 2013, 3:14 PM
#4
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

Hi Ajeh,

This was the mod in it's original state:

http://www.zen-cart.com/downloads.php?do=file&id=346

However, we've been playing with it somewhat:

includes/modules/payment/accountholder.php

<?php

  class accountholder {
    var $code, $title, $description, $enabled;

// class constructor
    function accountholder() {
      global $order;

      $this->code = 'accountholder';
      $this->title = MODULE_PAYMENT_ACCOUNTHOLDER_TEXT_TITLE;
      if (IS_ADMIN_FLAG === true && (MODULE_PAYMENT_ACCOUNTHOLDER_PAYTO == 'Just pay the rest when you can' || MODULE_PAYMENT_ACCOUNTHOLDER_PAYTO == '')) $this->title .= '<span class="alert"> </span>';
      $this->description = MODULE_PAYMENT_ACCOUNTHOLDER_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_PAYMENT_ACCOUNTHOLDER_SORT_ORDER;
      $this->enabled = ((MODULE_PAYMENT_ACCOUNTHOLDER_STATUS == 'True') ? true : false);
	  if (!IS_ADMIN_FLAG) {
  global $cart;
  if ($_SESSION['cart']->show_weight() == 0) {
    $this->enabled = false;
  }
}
	  
	  // bof: disable based on Order Amount
// use $order->info['subtotal'] or $order->info['subtotal']
if (!IS_ADMIN_FLAG && $order->info['subtotal'] < 100.00) {
$this->enabled = false;
}
//echo 'I SEE ' . 'Subtotal: ' . $order->info['subtotal'] . ' Total: ' . $order->info['total'] . '<br>';
// eof: disable based on Order Amount 

      if ((int)MODULE_PAYMENT_ACCOUNTHOLDER_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_ACCOUNTHOLDER_ORDER_STATUS_ID;
      }

      if (is_object($order)) $this->update_status();
    
      $this->email_footer = MODULE_PAYMENT_ACCOUNTHOLDER_TEXT_EMAIL_FOOTER;
    }

// class methods
    function update_status() {
      global $order, $db;

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_ACCOUNTHOLDER_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_ACCOUNTHOLDER_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
        while (!$check->EOF) {
          if ($check->fields['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
            $check_flag = true;
            break;
          }
          $check->MoveNext();
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }
    }

    function javascript_validation() {
      return false;
    }

    function selection() {
      return array('id' => $this->code,
                   'module' => $this->title);
    }

    function pre_confirmation_check() {
      return false;
    }

    function confirmation() {
      return array('title' => MODULE_PAYMENT_ACCOUNTHOLDER_TEXT_DESCRIPTION);
    }

    function process_button() {
      return false;
    }

    function before_process() {
      return false;
    }

    function after_process() {
      return false;
    }

    function get_error() {
      return false;
    }

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_ACCOUNTHOLDER_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

    function install() {
      global $db;
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Account Holder Module', 'MODULE_PAYMENT_ACCOUNTHOLDER_STATUS', 'True', 'Do you want to activate the Account Holder payment option?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now());");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Make Payable to:', 'MODULE_PAYMENT_ACCOUNTHOLDER_PAYTO', 'Just pay the rest when you can', 'Who should payments be made payable to?', '6', '1', now());");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_ACCOUNTHOLDER_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_ACCOUNTHOLDER_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_ACCOUNTHOLDER_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
    }

    function remove() {
      global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_PAYMENT_ACCOUNTHOLDER_STATUS', 'MODULE_PAYMENT_ACCOUNTHOLDER_ZONE', 'MODULE_PAYMENT_ACCOUNTHOLDER_ORDER_STATUS_ID', 'MODULE_PAYMENT_ACCOUNTHOLDER_SORT_ORDER', 'MODULE_PAYMENT_ACCOUNTHOLDER_PAYTO');
    }
  }
?>

/includes/languages/english/modules/payment/accountholder.php

<?php
  define('MODULE_PAYMENT_ACCOUNTHOLDER_TEXT_TITLE', '<img src="https://www.silkblooms.co.uk/includes/templates/freetemplate2/images/arrow.gif" class="GCWeeButton"> Pay by Instalments');
  define('MODULE_PAYMENT_ACCOUNTHOLDER_TEXT_DESCRIPTION', 'Please use this link to pay your deposit: http://www.silkblooms.co.uk/pay/<br />' . MODULE_PAYMENT_ACCOUNTHOLDER_PAYTO . '<br /><br />Thank you for shopping at:<br />' . nl2br(STORE_NAME_ADDRESS) . '<br /><br />' . '');
  define('MODULE_PAYMENT_ACCOUNTHOLDER_TEXT_EMAIL_FOOTER', "Please use this link to pay your deposit: http://www.silkblooms.co.uk/pay/" . "\n\n" . MODULE_PAYMENT_ACCOUNTHOLDER_PAYTO . "\n\nThank you for shopping with:\n" . STORE_NAME_ADDRESS . "\n\n" . '');
?>

/includes/languages/english/CUSTOM/checkout_payment.php

<?php

define('NAVBAR_TITLE_1', 'Checkout - Step 1');
define('NAVBAR_TITLE_2', 'Payment Method - Step 2');

define('HEADING_TITLE', 'Step 2 of 3 - Payment Information');

define('TABLE_HEADING_BILLING_ADDRESS', 'Billing Address');
define('TEXT_SELECTED_BILLING_DESTINATION', 'Your billing address is shown to the left. The billing address should match the address on your credit card statement. You can change the billing address by clicking the <em>Change Address</em> button.');
define('TITLE_BILLING_ADDRESS', 'Billing Address:');

define('TABLE_HEADING_PAYMENT_METHOD', 'Payment Method');

      /*The following line can be adjusted to include/alter appropriate text description for the Account Holders Only payment option
      DO NOT comment out the line... just alter the text description if necessary */
       
define('TEXT_SELECT_PAYMENT_METHOD', 'Please select a payment method for this order.<br /><br />Authorised Account Holders may use the <strong>Account Holders Only</strong> payment option.<br /><br />If you are <strong>not</strong> an Authorised Account Holder, your order may not be processed, so please choose other payment options.');

define('TITLE_PLEASE_SELECT', 'Please Select');
define('TEXT_ENTER_PAYMENT_INFORMATION', '');
define('TABLE_HEADING_COMMENTS', 'Special Instructions or Order Comments');

define('TITLE_NO_PAYMENT_OPTIONS_AVAILABLE', 'Not Available At This Time');
define('TEXT_NO_PAYMENT_OPTIONS_AVAILABLE','<span class="alert">Sorry, we are not accepting payments from your region at this time.</span><br />Please contact us for alternate arrangements.');

define('TITLE_CONTINUE_CHECKOUT_PROCEDURE', '<strong>Continue to Step 3</strong>');
define('TEXT_CONTINUE_CHECKOUT_PROCEDURE', '- to confirm your order.');

define('TABLE_HEADING_CONDITIONS', '<span class="termsconditions">Terms and Conditions</span>');
define('TEXT_CONDITIONS_DESCRIPTION', '<span class="termsdescription">Please acknowledge the terms and conditions bound to this order by ticking the following box. The terms and conditions can be read <a href="' . zen_href_link(FILENAME_CONDITIONS, '', 'SSL') . '"><span class="pseudolink">here</span></a>.');
define('TEXT_CONDITIONS_CONFIRM', '<span class="termsiagree">I have read and agreed to the terms and conditions bound to this order.</span>');

define('TEXT_CHECKOUT_AMOUNT_DUE', 'Total Amount Due: ');
define('TEXT_YOUR_TOTAL','Your Total');
?>
10 Jan 2013, 3:41 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

The way this is written ...

If Weight = 0, it will not show ...

If Amount is < 100, it will not show ...

So if you have a Virtual Product ... that will not show ...

And if you have an Always Free Shipping Product ... that will not show ...

You have the conditions being set by:

      if (!IS_ADMIN_FLAG) {
  global $cart;
  if ($_SESSION['cart']->show_weight() == 0) {
    $this->enabled = false;
  }
}

      // bof: disable based on Order Amount
// use $order->info['subtotal'] or $order->info['subtotal']
if (!IS_ADMIN_FLAG && $order->info['subtotal'] < 100.00) {
$this->enabled = false;
}

Is this perhaps what is giving you grief?

10 Jan 2013, 4:22 PM
#6
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

Hi Ajeh,

I remember that now! Yes, this is a sort of paradox as I need both of those statements in there.

<100 needs to be there so the option isn't available on orders below this monetary value.

There may be an alternative to "if weight = 0" though. If I recall rightly, we added this in so that it wouldn't appear as an option when product ID 1652 is in their cart. I may be wrong on that. We have the weight of product ID 1652 set to 0 so that this payment option doesn't work for this. (1652 is the method they use to pay an instalment towards their main order you see). All other products have a weight above zero.

Would there be a way to change "if weight = 0" to "if product ID 1652 is in your cart"?

10 Jan 2013, 4:37 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

Perhaps using:

$_SESSION['cart']->get_quantity(1652) > 0

10 Jan 2013, 6:16 PM
#8
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

This is brilliant Ajeh! This one's been annoying me since we started this site! Slowly but surely you're helping me get rid of all the glitches that are niggling away at me :) You have an amazing head for all this!!

Now, on to the next thing.......

10 Jan 2013, 6:26 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

Thanks for the update that this is now working ... remember the Zen Cart Team when you are rich and famous! :cool:

10 Jan 2013, 6:34 PM
#10
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

Ajeh:

Thanks for the update that this is now working ... remember the Zen Cart Team when you are rich and famous! :cool:

I will, definitely! Meantime, I've just bought you all a few coffees!

http://www.zen-cart.com/donate (d)

10 Jan 2013, 7:13 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD - Cash on Delivery Payment Module - Customised - Make it Work with Free Shipping

Thank you kindly ... we really appreciate the support! :cool: