Jump to content


Corporate Sponsors


Latest News: (loading..)

JuanIgnacio

Member Since 01 Mar 2006
Offline Last Active Dec 28 2011, 18:25
-----

Posts I've Made

In Topic: Zone doesn't work but no error

06 July 2011, 17:31

Update. Here's the module:



<?php
/*
  $Id: Interstate.php
  Hecho por Formato Diseño

  For Use with:
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Released under the GNU General Public License
*/


  class oca_express {
    var $code, $title, $description, $enabled, $num_zones;

// class constructor
    function oca_express() {
      $this->code = 'oca_express';
      $this->title = OCA_EXPRESS_TEXT_TITLE;
      $this->description = OCA_EXPRESS_TEXT_DESCRIPTION;
      $this->sort_order = OCA_EXPRESS_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = OCA_EXPRESS_TAX_CLASS;
      $this->enabled = ((OCA_EXPRESS_STATUS == 'True') ? true : false);

      // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
      $this->num_zones = 2;
    }

// class methods
    function quote($method = '') {
      global $order, $shipping_weight, $shipping_num_boxes;

      // if delivery is to other country, skip module in cart
     // if ($order->delivery['country']['iso_code_2'] != 'AR	') return;


      //$dest_state = $order->delivery['estado']; 
      $dest_iz = tep_db_fetch_array(tep_db_query("select zone_code from zones where zone_id = '" . (int)$order->delivery['zone_id'] . "'"));
	  $dest_state =  $dest_iz['zone_code'];
	  
	  $dest_nam = tep_db_fetch_array(tep_db_query("select zone_name from zones where zone_id = '" . (int)$order->delivery['zone_id'] . "'"));
	  $dest_nombre =  $dest_nam['zone_name'];
	  
	  $dest_zone = 0;
      $error = false;

      for ($i=1; $i<=$this->num_zones; $i++) {
        $state_table = constant('OCA_EXPRESS_STATES_' . $i);
        $state_zones = split("[ ,]", $state_table);
        if (in_array($dest_state, $state_zones)) {
          $dest_zone = $i;
          break;
        }
      }
      if ($dest_zone == 0) {
        $error = true;
      } else {
        $shipping = -1;
        $OCA_EXPRESS_cost = constant('OCA_EXPRESS_COST_' . $dest_zone);
        $OCA_EXPRESS_table = split("[:,]" , $OCA_EXPRESS_cost);
        $size = sizeof($OCA_EXPRESS_table);
        for ($i=0; $i<$size; $i+=2) {
          if ($shipping_weight <= $OCA_EXPRESS_table[$i]) {
            $shipping = $OCA_EXPRESS_table[$i+1];
            $shipping_method = OCA_EXPRESS_TEXT_WAY . ' a '. $dest_nombre;
            break;
          }
        }

        if ($shipping == -1) {
          $shipping_cost = 0;
          $shipping_method = OCA_EXPRESS_UNDEFINED_RATE;
        } else {
          $shipping_cost = ($shipping * $shipping_num_boxes);
        }
      }

      $this->quotes = array('id' => $this->code,
                            'module' => OCA_EXPRESS_TEXT_SECTION_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => $shipping_method,
                                                     'cost' => $shipping_cost)));

      if ($this->tax_class > 0) {
        $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }

      if (tep_not_null($this->icon)) $this->quotes['icon'] = 
				 tep_image($this->icon, $this->title);

      if ($error == true) $this->quotes['error'] = OCA_EXPRESS_INVALID_ZONE;

      return $this->quotes;
    }

    function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'OCA_EXPRESS_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }
      return $this->_check;
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ( 'Habilitar Correo Argentino?', 'OCA_EXPRESS_STATUS', 'True', 'Habilitar Correo Argentino?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ( 'Impuesto', 'OCA_EXPRESS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ( 'Orden de aparici&oacute;n', 'OCA_EXPRESS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

      for ($i = 1; $i <= $this->num_zones; $i++) {
        $default_states = '';
        $default_rates = '';
        if ($i == 1) {
          $default_states = 'CF, BA, ZC, ZR, ZP'; // Capital - Regional
          $default_rates = '1:29, 5:35';
        }
        if ($i == 2) {
			  $default_states = 'SF, CB, ER, LP, CO, CA, CC, CH, FO, JU, LR, MZ, MI, NE, RN, SA, SJ, SL, SC, SE, TU, TF '; // Nacional 
          $default_rates = '1:41, 5:53';
        }
        if ($i == 3) { // Otros
          $default_states = '';
          $default_rates = '';
        }

				
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zona " . $i ." - Provincias', 'OCA_EXPRESS_STATES_" . $i ."', '" . $default_states . "', 'Lista de codigos ISO de las provincias en la zona separados por comas', '6', '0', now())");
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zone " . $i ." - Rango de precios', 'OCA_EXPRESS_COST_" . $i ."', '" . $default_rates . "', 'Precios para la Zona " . $i . " en formato rangos. Ejemplo: 3:8.50,7:10.50, (...) Con peso menos o igual a 3 cuesta 8.50 para desinos en la Zona " . $i . ".', '6', '0', now())");
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zone " . $i ." - Recargo fijo', 'OCA_EXPRESS_HANDLING_" . $i."', '0.00', 'Handling Fee for this shipping zone', '6', '0', now())");
      }
    }

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

    function keys() {
      $keys = array('OCA_EXPRESS_STATUS', 'OCA_EXPRESS_TAX_CLASS', 'OCA_EXPRESS_SORT_ORDER');
      for ($i=1; $i<=$this->num_zones; $i++) {
        $keys[] = 'OCA_EXPRESS_STATES_' . $i;
        $keys[] = 'OCA_EXPRESS_COST_' . $i;
        $keys[] = 'OCA_EXPRESS_HANDLING_' . $i;
      }
      return $keys;
    }
  }
?>


In Topic: Credit Class & Gift Vouchers (CCGV) for 2.3.1

09 May 2011, 20:34

Would be nice to have it

Can you send it please?

You should also contribute it to the AddOn Page

In Topic: Credit Class & Gift Vouchers (CCGV) for 2.3.1

09 May 2011, 15:32

Found that

function credit_selection() { ... }

in /includes/modules/order_total/ot_coupon.php un line 61 is the responsable for outputting the coupon code input field text

You have to be sure that function is called in checkout_payment.php



// Start - CREDIT CLASS Gift Voucher Contribution
        echo $order_total_modules->credit_selection();
// End - CREDIT CLASS Gift Voucher Contribution 

but of course, all the checking and class creation code must be correctly on the first part of checkout_payment.php for it to work

I'll be posting more on this later

In Topic: Credit Class & Gift Vouchers (CCGV) for 2.3.1

08 May 2011, 06:54

You installed it into osCommerce 2.3.1?

I started comparing files and editing the original 2.3.1... I manage to port all the admin part (which I'll contribute later) but I can't fin the way to place the box where the user inputs his coupon code.