Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23
  1. #21
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Special Shipping for fragile products

    Quote Originally Posted by 2mymall View Post
    Ran into a problem with "perweightunit.php"
    It does not have a //class constructor.

    Where do I add the code in "perweightunit.php"?
    The comment (line that begins with //) may be missing, but comments are generally ignored by code. For this module the constructor identifier in ZC 1.5.1 was placed within a different comment structure (/* comment that can span many lines */).

    You are looking for a section that begins or includes the word function with at least one space before and after followed by either the name of the class (perweightunit) or for code that works in old ZC versions but will work in PHP 7.0+ you would be looking for __construct.

    The first type of constructor is included in ZC 1.5.1 shipping module perweightunit.php:
    Code:
    /**
         * Constructor
       *
       * @return perweightunit
       */
      function perweightunit() {
        global $order, $db;
        $this->code = 'perweightunit';
        $this->title = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_PERWEIGHTUNIT_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_BASIS;
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_PERWEIGHTUNIT_STATUS == 'True') ? true : false);
        }
        if ($this->enabled) {
          // check MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING_METHOD is in
          $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING_METHOD'");
          if ($check_query->EOF) {
            $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING_METHOD', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
          }
        }
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_PERWEIGHTUNIT_ZONE > 0) ) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . "
                                 where geo_zone_id = '" . MODULE_SHIPPING_PERWEIGHTUNIT_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;
          }
        }
      }
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #22
    Join Date
    May 2010
    Posts
    22
    Plugin Contributions
    0

    Default Re: Special Shipping for fragile products

    Code:
      var $enabled;
      /**
         * Constructor
       *
       * @return perweightunit
       */
      function perweightunit() {
        global $order, $db;
    
        $this->code = 'perweightunit';
        $this->title = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_PERWEIGHTUNIT_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_BASIS;
    
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_PERWEIGHTUNIT_STATUS == 'True') ? true : false);
        }
    // FRAGILE_PRODUCTS_CATEGORY is defined in includes/extra_configures/fragile_product_categories.php
    $categories_list = array_map('zen_string_to_int', explode(',', FRAGILE_PRODUCTS_CATEGORY));
    foreach ($order->products as $current_product) {
        foreach ($categories_list as $category_id) {
            if (zen_product_in_category($current_product['id'], $category_id)) {
                $this->enabled = false;
                break 2; //Completely exit the order->products review
            }
        }
    }
    Is this correct?

  3. #23
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Special Shipping for fragile products

    Quote Originally Posted by 2mymall View Post
    Code:
      var $enabled;
      /**
         * Constructor
       *
       * @return perweightunit
       */
      function perweightunit() {
        global $order, $db;
    
        $this->code = 'perweightunit';
        $this->title = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_PERWEIGHTUNIT_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_BASIS;
    
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_PERWEIGHTUNIT_STATUS == 'True') ? true : false);
        }
    // FRAGILE_PRODUCTS_CATEGORY is defined in includes/extra_configures/fragile_product_categories.php
    $categories_list = array_map('zen_string_to_int', explode(',', FRAGILE_PRODUCTS_CATEGORY));
    foreach ($order->products as $current_product) {
        foreach ($categories_list as $category_id) {
            if (zen_product_in_category($current_product['id'], $category_id)) {
                $this->enabled = false;
                break 2; //Completely exit the order->products review
            }
        }
    }
    Is this correct?
    Of the amount of code that is presented and that the inserted code hasn't been visually adjusted further to the right to account for where in the series of braces it is executed, it looks correct. Technically there should be more code below it so that the constructor is properly closed out.

    Basically here, a code block is being inserted and that code block should already contain all of the left and right curly brackets '{' and '}' should already be correct and added to/within the existing code.

    If not, you are likely to have a php error with blank screen that will get documented in your logs directory as discussed before.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 3 of 3 FirstFirst 123

Similar Threads

  1. Special shipping surcharge for a few products
    By Sarah808 in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 20 Aug 2012, 10:06 PM
  2. Special Shipping for certain products
    By 2mymall in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 1 Jun 2010, 01:32 PM
  3. Special shipping for some products in a zone
    By trec in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 21 May 2008, 06:56 AM
  4. Special shipping for some products
    By Erik011 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 6 Feb 2008, 03:19 PM
  5. Disable shipping when product is fragile?
    By xman888 in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 16 Jan 2008, 12:27 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR