If this is your first visit, check our documentation. To post, register or login.
Forums / Addon Shipping Modules / Coders I need help

Coders I need help

Locked

Started by christoph100 on 2 Oct 2007, 4:03 PM · Views: 1,688

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
2 Oct 2007, 4:03 PM
#1
christoph100 avatar

christoph100

New Zenner

Join Date:
Sep 2007
Posts:
18
Plugin Contributions:
0

Coders I need help

Hi all I am working on my next project. I am porting over another osc module this time its a city delivery module.. I must be missing something,I have all the code switched for zen that needs to be switched but I get this error when I try to install it in zen. Can anyone here give any ideas to correct this.?

1136 Column count doesn't match value count at row 1
in:
[insert into zenconfiguration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', 'True', 'Do you want to offer City Delivery?', '6', '0', 'zen_cfg_select_option(array('True', 'False'), ', now())]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

Here is the database insertion code.

  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', 'True', 'Do you want to offer City Delivery?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");

// BOF Determine if costs table is based on price or weight
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Delivery Cost Method', 'MODULE_SHIPPING_DLYC_MODE', 'weight', 'The delivery cost is based on the order total or the total weight of the items ordered.', '6', '0', 'zen_cfg_select_option(array('weight', 'price'), ', now())");
// EOF Determine if costs table is based on price or weight
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Local Delivery Cost', 'MODULE_SHIPPING_DLYC_COST', '25:8.50,50:5.50,10000:0.00', 'The delivery cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc. Be aware: The Handling fee will NOT be added.', '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 ('Tax Class', 'MODULE_SHIPPING_DLYC_TAX_CLASS', '0', 'Use the following Tax Class on the Shipping Fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
// Beg Minimum Order Total required to activate module
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Order Total', 'MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL', '0.00', 'What is the Minimum Order Total required for this option to be activated.', '6', '0', now())");
// End Minimum Order Total required to activate module
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Local Delivery Distance', 'MODULE_SHIPPING_DLYC_MAX_LOCAL_DISTANCE', '12 Km', 'What is the Maximum Local delivery distance which you will travel to deliver orders. [ ie. 12 Km ]', '6', '0', now())");
// Begin City
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('City', 'MODULE_SHIPPING_DLYC_CITY', '', 'Only enable this shipping method for these cities. Separate with comma if several, empty if all.', '6', '0', now())");
// End City
$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 ('Shipping Zone', 'MODULE_SHIPPING_DLYC_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', '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, date_added) values ('Sort Order', 'MODULE_SHIPPING_DLYC_SORT_ORDER', '3', 'Sort order of display.', '6', '0', now())");
}

Thanks for looking
Chris.

2 Oct 2007, 8:40 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Coders I need help

christoph100:

**1136 Column count doesn't match value count **at row 1
in:
[insert into zenconfiguration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', 'True', 'Do you want to offer City Delivery?', '6', '0', 'zen_cfg_select_option(array('True', 'False'), ', now())]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.The number of column-names specified in your INSERT statement doesn't match the number of values you're supplying to insert into those columns.

(configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added)
vs
('Enable City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', 'True', 'Do you want to offer City Delivery?', '6', '0', 'zen_cfg_select_option(array('True', 'False'), ', now())

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Oct 2007, 5:54 AM
#3
christoph100 avatar

christoph100

New Zenner

Join Date:
Sep 2007
Posts:
18
Plugin Contributions:
0

Re: Coders I need help

Ok thanks for the reply I am still trying to understand it. '6','0' is that a location in the database? if not what is it exactly?

also here is the original section of code from osc...
I tried using the exact numbers it had but it still gives me the same error. There is something I am not quite getting, I am trying to learn tho.

original section of code osc.

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', '1', 'Do you want to offer City Delivery?', '6', '5', now())"); leaving this part of the code like this but changing it for a database call zen style, gives option to install but it wont, no error either reported but the status light changes from red to yellow but I know this is not correct format for zen. need the array with true/false section.^^^^^^^^^^^^^^^^^^^

// BOF Determine if costs table is based on price or weight
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 ('Delivery Cost Method', 'MODULE_SHIPPING_DLYC_MODE', 'weight', 'The delivery cost is based on the order total or the total weight of the items ordered.', '6', '2', 'tep_cfg_select_option(array('weight', 'price'), ', now())");
// EOF Determine if costs table is based on price or weight
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Local Delivery Cost', 'MODULE_SHIPPING_DLYC_COST', '25:8.50,50:5.50,10000:0.00', 'The delivery cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc. Be aware: The Handling fee will NOT be added.', '6', '4', 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 ('Tax Class', 'MODULE_SHIPPING_DLYC_TAX_CLASS', '0', 'Use the following Tax Class on the Shipping Fee.', '6', '6', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
// Beg Minimum Order Total required to activate module
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Order Total', 'MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL', '0.00', 'What is the Minimum Order Total required for this option to be activated.', '6', '7', now())");
// End Minimum Order Total required to activate module
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Local Delivery Distance', 'MODULE_SHIPPING_DLYC_MAX_LOCAL_DISTANCE', '12 Km', 'What is the Maximum Local delivery distance which you will travel to deliver orders. [ ie. 12 Km ]', '6', '10', now())");
// Begin City
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('City', 'MODULE_SHIPPING_DLYC_CITY', '', 'Only enable this shipping method for these cities. Separate with comma if several, empty if all.', '6', '7', now())");
// End City
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 ('Shipping Zone', 'MODULE_SHIPPING_DLYC_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_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 ('Sort Order', 'MODULE_SHIPPING_DLYC_SORT_ORDER', '3', 'Sort order of display.', '6', '0', now())");
}
this works in osc with no problem.
Suggestions? What is it that I am not understanding?
Thank again
Chris.

3 Oct 2007, 6:18 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Coders I need help

DrByte:

The number of column-names specified in your INSERT statement doesn't match the number of values you're supplying to insert into those columns.

(configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, **set_function, **date_added)
vs
('Enable City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', 'True', 'Do you want to offer City Delivery?', '6', '0', 'zen_cfg_select_option(array('True', 'False'), ', now())

You are specifying a function, but not telling it what function to use. Add it as shown above.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Oct 2007, 7:06 AM
#5
christoph100 avatar

christoph100

New Zenner

Join Date:
Sep 2007
Posts:
18
Plugin Contributions:
0

Re: Coders I need help

Thank you, still not quite working right ....still shows yellow when installed but I am a bit closer now to completion, I'm learning.
Chris.

3 Oct 2007, 7:16 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Coders I need help

Yellow means that the module has been installed but likely has some restrictions activated in the various settings it offers ... or hasn't been coded to Zen Cart standards ... the latter wouldn't be surprising for code written for another system besides Zen Cart.

Rather than worrying about "yellow", you should be focused on whether the module produces the right results in your store.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Oct 2007, 4:23 AM
#7
christoph100 avatar

christoph100

New Zenner

Join Date:
Sep 2007
Posts:
18
Plugin Contributions:
0

Re: Coders I need help

I am still working on it, I have it so that it can now go through check out process #1 but the check out process #2 wont work yet. at the 1st process it gives the options correctly but then where it says to continue to checkout step 2 there is no button to continue, (still learning :)

Chris.

16 Oct 2007, 4:09 PM
#8
christoph100 avatar

christoph100

New Zenner

Join Date:
Sep 2007
Posts:
18
Plugin Contributions:
0

Re: Coders I need help

Well I have been working on this now for awile and I just can't seem to get it to install correctly, Its shows its there and allows me to fill in the information. I thought perhaps it was missing tax_basis cause all other modules have it so I added it. Still the same problem. What could I be doing wrong, Am I missing something? here is the modified code I have so far, I know I am close and I would like this to actually work as its a requirement for my store. Can someone that has knowledge with code take a look at this?

  class dlyc {
    var $code, $title, $description, $icon, $enabled;

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

      $this->code = 'dlyc';
      $this->title = MODULE_SHIPPING_DLYC_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_DLYC_TEXT_DESCRIPTION;
	  $this->tax_class = MODULE_SHIPPING_DLYC_TAX_CLASS;
	    $this->tax_basis = MODULE_SHIPPING_DLYC_TAX_BASIS;
      $this->sort_order = MODULE_SHIPPING_DLYC_SORT_ORDER;
      $this->icon = DIR_WS_IMAGES . 'shipping_dly.gif';  // To remove icon change this line to: $this->icon = '';
      $this->enabled = MODULE_SHIPPING_DLYC_STATUS;
// Beg Minimum Order Total required to activate module
      $this->min_order = MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL;

    if ( ($order->info['total']) < ($this->min_order) )  {
          $this->enabled = false;
    }
// End Minimum Order Total required to activate module
   
	  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_DLYC_ZONE > 0) ) {
        $check_flag = false;
        $check_query = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_DLYC_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
		$city = split("[:,]" ,MODULE_SHIPPING_DLYC_CITY);
				$zip_up = MODULE_SHIPPING_DLYC_CITY;
		$zip_up = strtoupper($zip_up);
		$zip_up = str_replace (' ', '', $zip_up);
		$city = split (',', $zip_up);		
		$order->delivery['city'] = ($order->delivery['city']);

       while (!$check->EOF) {
         if ($check->fields['zone_id'] < 1) {
		    if ((in_array($order->delivery['city'],$city )) or (MODULE_SHIPPING_DLYC_CITY==''))
              $check_flag = true;
            break;
          } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
		      if ((in_array($order->delivery['city'],$city )or (MODULE_SHIPPING_DLYC_CITY=='')))
                $check_flag = true;
            break;
          }
		}

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

// class methods

    function quote($method = '') {
	  global $order, $cart, $shipping_weight, $shipping_num_boxes;

      if (MODULE_SHIPPING_DLYC_MODE == 'price') {
      $order_total = $cart;
      } else {
      $order_total = $shipping_weight;
      }

      $table_cost = split("[:,]" , MODULE_SHIPPING_DLYC_COST);
      $shipping_rate = 0;
      $size = sizeof($table_cost);
      for ($i=0, $n=$size; $i<$n; $i+=2) {
        if ($order_total <= $table_cost[$i]) {
          $shipping_rate = $table_cost[$i+1];
          break;
        }
      }

      if (MODULE_SHIPPING_DLYC_MODE == 'weight') {
        $shipping_rate = $shipping_rate * $shipping_num_boxes;
      }

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_DLYC_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_DLYC_TEXT_WAY,
                                                     'cost' =>  $shipping_rate)));

      

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

    if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
     
    return $this->quotes;
    }

    function check() {
    global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_DLYC_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 City Delivery', 'MODULE_SHIPPING_DLYC_STATUS', 'true', 'Do you want to offer City Delivery?', '6', '0', '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, set_function, date_added) values ('Delivery Cost Method', 'MODULE_SHIPPING_DLYC_MODE', 'weight', 'The delivery cost is based on the order total or the total weight of the items ordered.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\'), ', now())");	  
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Local Delivery Cost', 'MODULE_SHIPPING_DLYC_COST', '25:8.50,50:5.50,10000:0.00', 'The delivery cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc. Be aware: The Handling fee will NOT be added.', '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 ('Tax Class', 'MODULE_SHIPPING_DLYC_TAX_CLASS', '0', 'Use the following Tax Class on the Shipping Fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_DLYC_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\'), ', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Order Total', 'MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL', '0.00', 'What is the Minimum Order Total required for this option to be activated.', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Local Delivery Distance', 'MODULE_SHIPPING_DLYC_MAX_LOCAL_DISTANCE', '12 Km', 'What is the Maximum Local delivery distance which you will travel to deliver orders. [ ie. 12 Km ]', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('City', 'MODULE_SHIPPING_DLYC_CITY', '', 'Only enable this shipping method for these cities. Separate with comma if several, empty if all.', '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 ('Shipping Zone', 'MODULE_SHIPPING_DLYC_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', '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, date_added) values ('Sort Order', 'MODULE_SHIPPING_DLYC_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
    }


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

    function keys() {
      return array('MODULE_SHIPPING_DLYC_STATUS', 'MODULE_SHIPPING_DLYC_MODE', 'MODULE_SHIPPING_DLYC_COST', 'MODULE_SHIPPING_DLYC_TAX_CLASS', 'MODULE_SHIPPING_DLYC_TAX_BASIS', 'MODULE_SHIPPING_DLYC_MINIMUM_ORDER_TOTAL', 'MODULE_SHIPPING_DLYC_MAX_LOCAL_DISTANCE', 'MODULE_SHIPPING_DLYC_CITY', 'MODULE_SHIPPING_DLYC_ZONE', 'MODULE_SHIPPING_DLYC_SORT_ORDER', );               
    }
  }
?>

And this module does install with out error reports so I am not sure whats going on.
Ideas?

Thanks
Chris.

16 Oct 2007, 4:34 PM
#9
christoph100 avatar

christoph100

New Zenner

Join Date:
Sep 2007
Posts:
18
Plugin Contributions:
0

Re: Coders I need help

got it working