Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Aug 2008
    Posts
    274
    Plugin Contributions
    0

    Default Custom Item.php ---PHP error--help please

    I am editing one of my shipping modules.

    BAsically I am checking to see if someone ordered an item from a category, if they did I need to add $15

    I am very close to having it figured out but I have a syntac error I can't figure out.



    This code is in my item.php page. When I enter it the shipping page pulls up blank and when I research it this is the error message. I'm not sure what else to put to make it work

    here is the error

    *************************
    [27-Apr-2011 09:41:12] PHP Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/image/public_html/grimmandgorly.com/cart/includes/modules/shipping/item.php on line 131



    *****here is the code, line 131 is this one

    if ($this->$chk_flowers >0) {'cost' => ('cost' + 15)};


    *******************************************

    global $cart;
    $chk_flowers = $_SESSION['cart']->in_cart_check('master_categories_id','14');


    if ($this->$chk_flowers >0) {'cost' => ('cost' + 15)};





    thanks

  2. #2
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    6,196
    Plugin Contributions
    0

  3. #3
    Join Date
    Aug 2008
    Posts
    274
    Plugin Contributions
    0

    Default Re: Custom Item.php ---PHP error--help please

    sorry, just thought posting it under the shipping modules instead of general might get it noticed by the right people. I know it has to be something simple I just can't figure it out

  4. #4
    Join Date
    Aug 2008
    Posts
    274
    Plugin Contributions
    0

    Default Re: Custom Item.php ---PHP error--help please

    any ideas, anyone??

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Custom Item.php ---PHP error--help please

    Could you post the whole function quote rather than a piece of it?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Aug 2008
    Posts
    274
    Plugin Contributions
    0

    Default Re: Custom Item.php ---PHP error--help please

    Gladly, thank you Linda,


    here is that section of the code


    $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();

    $this->quotes = array('id' => $this->code,

    'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,

    'methods' => array(array('id' => $this->code,

    'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,

    'cost' => (MODULE_SHIPPING_ITEM_COST * $item_total_count) + MODULE_SHIPPING_ITEM_HANDLING)));




    global $cart;
    $chk_flowers = $_SESSION['cart']->in_cart_check('master_categories_id','14');


    if ($this->$chk_flowers>0) {

    {'cost' => 'cost' + 15;
    }


    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;

    }



    The entire file is

    ********************************


    <?php

    /**

    * @package shippingMethod

    * @copyright Copyright 2003-2009 Zen Cart Development Team

    * @copyright Portions Copyright 2003 osCommerce

    * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

    * @version $Id: item.php 14498 2009-10-01 20:16:16Z ajeh $

    */





    class item {

    var $code, $title, $description, $icon, $enabled;



    // class constructor

    function item() {

    global $order, $db;



    $this->code = 'item';

    $this->title = MODULE_SHIPPING_ITEM_TEXT_TITLE;

    $this->description = MODULE_SHIPPING_ITEM_TEXT_DESCRIPTION;

    $this->sort_order = MODULE_SHIPPING_ITEM_SORT_ORDER;

    $this->icon = '';

    $this->tax_class = MODULE_SHIPPING_ITEM_TAX_CLASS;

    $this->tax_basis = MODULE_SHIPPING_ITEM_TAX_BASIS;



    // disable only when entire cart is free shipping

    if (zen_get_shipping_enabled($this->code)) {

    $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false);

    }



    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEM_ZONE > 0) ) {

    $check_flag = false;

    $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ITEM_ZONE . "' and zone_country_id = '" . $order->delivery['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->delivery['zone_id']) {

    $check_flag = true;

    break;

    }

    $check->MoveNext();

    }



    if ($check_flag == false) {

    $this->enabled = false;

    }

    }

    }



    // class methods

    function quote($method = '') {

    global $order, $total_count;



    // adjusted count for free shipping

    $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();

    $this->quotes = array('id' => $this->code,

    'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,

    'methods' => array(array('id' => $this->code,

    'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,

    'cost' => (MODULE_SHIPPING_ITEM_COST * $item_total_count) + MODULE_SHIPPING_ITEM_HANDLING)));




    global $cart;
    $chk_flowers = $_SESSION['cart']->in_cart_check('master_categories_id','14');


    if ($this->$chk_flowers>0) {

    {'cost' => 'cost' + 15;
    }


    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_ITEM_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 Item Shipping', 'MODULE_SHIPPING_ITEM_STATUS', 'True', 'Do you want to offer per item rate shipping?', '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, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_ITEM_COST', '2.50', 'The shipping cost will be multiplied by the number of items in an order that uses this shipping method.', '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 ('Handling Fee', 'MODULE_SHIPPING_ITEM_HANDLING', '0', 'Handling fee for this shipping method.', '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_ITEM_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_ITEM_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\', \'Store\'), ', 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_ITEM_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_ITEM_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

    }



    function remove() {

    global $db;

    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_ITEM\_%'");

    }



    function keys() {

    return array('MODULE_SHIPPING_ITEM_STATUS', 'MODULE_SHIPPING_ITEM_COST', 'MODULE_SHIPPING_ITEM_HANDLING', 'MODULE_SHIPPING_ITEM_TAX_CLASS', 'MODULE_SHIPPING_ITEM_TAX_BASIS', 'MODULE_SHIPPING_ITEM_ZONE', 'MODULE_SHIPPING_ITEM_SORT_ORDER');

    }

    }

    ?>


    **********

    thank you

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Custom Item.php ---PHP error--help please

    Try this change instead:
    Code:
          // adjusted count for free shipping
          $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();
    global $cart;
    $chk_flowers = $_SESSION['cart']->in_cart_check('master_categories_id','14');
    if ($chk_flowers > 0) {
      $chk_flowers = 15.00;
    } else {
      $chk_flowers = 0;
    }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,
                                                         'cost' => (MODULE_SHIPPING_ITEM_COST * $item_total_count) + MODULE_SHIPPING_ITEM_HANDLING + $chk_flowers)));
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #8
    Join Date
    Aug 2008
    Posts
    274
    Plugin Contributions
    0

    Default Re: Custom Item.php ---PHP error--help please

    Thank you Linda,

    I'm getting closer, no errors this time but it won't add the $15 fee.

    The site is https://www.grimmandgorly.com/cart/i...fecaction=null

    The goal is that if anyone orders anything from the flowers category (master cat 14) it will add a one time fee of $15 to the shipping total. Currently it is setup to charge $5 per item to ship, but if they select anything from the flower category I want to add an extra $15 to the order (only one time, so if they get one flower it will be an extra $15, if they select 6 different flowers it will still only be $15 extra)

    any ideas? thank you
    Last edited by Ajeh; 2 May 2011 at 04:36 PM. Reason: remove zenid never post in forums, emails, etc.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Custom Item.php ---PHP error--help please

    You are mistaking the Parent categories_id for the master_categories_id ...

    The master_categories_id is the categories_id of the immediate Category that the Product is in ...

    Example: Flowers ... Anniversary would use the master_categories_id of 15 ...

    So what you need to do is build the count from all of the master_categories_id that are being used ...

    Code:
    $chk_flowers = 0;
    $chk_flowers += $_SESSION['cart']->in_cart_check('master_categories_id','15');
    $chk_flowers += $_SESSION['cart']->in_cart_check('master_categories_id','16');
    $chk_flowers += $_SESSION['cart']->in_cart_check('master_categories_id','17');
    etc. etc. etc.
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #10
    Join Date
    Aug 2008
    Posts
    274
    Plugin Contributions
    0

    Default Re: Custom Item.php ---PHP error--help please

    Thanks,


    I just did that an put the "3 dozen rose bouquet" in the cart which is from category 15 and it isn't adding the extra $15, it is adding the $5 per item but I need it to not add anything per item except the flat $15


    any ideas?

    here is the code


    // adjusted count for free shipping
    $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();
    global $cart;


    $chk_flowers = 0;
    $chk_flowers += $_SESSION['cart']->in_cart_check('master_categories_id','15');
    $chk_flowers += $_SESSION['cart']->in_cart_check('master_categories_id','16');
    $chk_flowers += $_SESSION['cart']->in_cart_check('master_categories_id','17');


    if ($chk_flowers > 0) {
    $chk_flowers = 15.00;
    } else {
    $chk_flowers = 0;
    }

    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,
    'cost' => (MODULE_SHIPPING_ITEM_COST * $item_total_count) + MODULE_SHIPPING_ITEM_HANDLING + $chk_flowers)));

    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;

    }

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. Please Help! Parse Error - Group pricing .php
    By annettes in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 14 Apr 2011, 11:38 PM
  2. v1.3.7 and PHP 4.4.6 to PHP 5.2.1 Problems-Please Help
    By grncreek in forum General Questions
    Replies: 8
    Last Post: 26 Oct 2008, 01:46 AM
  3. Need *URGENT* HELP please!! Fatal Error order_total.php
    By gizmo_girl in forum General Questions
    Replies: 4
    Last Post: 1 Feb 2008, 07:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg