If this is your first visit, check our documentation. To post, register or login.
Forums / Upgrading Your Zen Cart / Upgrading to 2.x.x / 2.01 log file question

2.01 log file question

Started by foghead on 1 Sep 2024, 12:12 AM · Views: 2,258

Results 21 to 26 of 26
4 Sep 2024, 3:58 PM
#21
foghead avatar

foghead

New Zenner

Join Date:
Dec 2021
Location:
Tennessee
Posts:
43
Plugin Contributions:
0

Post #21 by foghead

Here's what happened after I added that code. I don't see a problem in line 165 what am I missing?

[04-Sep-2024 15:44:38 UTC] PHP Parse error: Unclosed '{' on line 165 does not match ')' in /includes/modules/shipping/table.php on line 166

[04-Sep-2024 15:44:38 UTC] Request URI: /index.php?main_page=checkout_shipping, IP address: 152.42.24.4
--> PHP Parse error: Unclosed '{' on line 165 does not match ')' in /includes/modules/shipping/table.php on line 166.

[04-Sep-2024 15:44:38 UTC] Request URI: /index.php?main_page=checkout_shipping, IP address: 152.42.24.4
--> PHP Parse error: Unclosed '{' on line 165 does not match ')' in /includes/modules/shipping/table.php on line 166.

Here's my edited code.

$shipping = 0;
for ($i=0, $n=$size; $i<$n; $i+=2) {
if (round($order_total,9) <= $table_cost[$i]) {
if (strstr($table_cost[$i+1], '%')) {
$shipping = (rtrim($table_cost[$i+1], '%')/100) * $order_total_amount;
} else {
$shipping = $table_cost[$i+1];
}
break;
}
}

4 Sep 2024, 5:12 PM
#22
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #22 by lat9

Would you post, this time enclosed in 'CODE' tags (that big # in the menu-bar when you write your response) the full contents of the table.php file's "quote" function?

4 Sep 2024, 5:41 PM
#23
foghead avatar

foghead

New Zenner

Join Date:
Dec 2021
Location:
Tennessee
Posts:
43
Plugin Contributions:
0

Post #23 by foghead

I hope I did this right. Thanks for putting up with my lack of knowledge.

 *  Obtain quote from shipping system/calculations
   *
   * @param string $method
   * @return unknown
   */
  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

    // shipping adjustment
    switch (MODULE_SHIPPING_TABLE_MODE) {
      case ('price'):
        $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        break;
      case ('weight'):
        $order_total = $shipping_weight;
        break;
      case ('item'):
        $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
        break;
    }

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

    $table_cost = preg_split("/[:,]/" , MODULE_SHIPPING_TABLE_COST);
    $size = sizeof($table_cost);
    $shipping = 0; 
    for ($i=0, $n=$size; $i<$n; $i+=2) {
      if (round($order_total,9) <= $table_cost[$i]) {
        if (strstr($table_cost[$i+1], '%')) {
          $shipping = (rtrim($table_cost[$i+1], '%')/100) * $order_total_amount;
        } else {
          $shipping = $table_cost[$i+1];
        }
        break;
      }
    }
4 Sep 2024, 6:04 PM
#24
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #24 by lat9

Yep, it looks like you lopped off some sections of that function. Use this, replacing lines 136-207 of the as-shipped zc201 version of the file:

  /**
   *  Obtain quote from shipping system/calculations
   *
   * @param string $method
   * @return unknown
   */
  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

    // shipping adjustment
    switch (MODULE_SHIPPING_TABLE_MODE) {
      case ('price'):
        $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        break;
      case ('weight'):
        $order_total = $shipping_weight;
        break;
      case ('item'):
        $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
        break;
    }

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

    $table_cost = preg_split("/[:,]/" , MODULE_SHIPPING_TABLE_COST);
    $size = sizeof($table_cost);
    $shipping = 0; 
    for ($i=0, $n=$size; $i<$n; $i+=2) {
      if (round($order_total,9) <= $table_cost[$i]) {
        if (strstr($table_cost[$i+1], '%')) {
          $shipping = (rtrim($table_cost[$i+1], '%')/100) * $order_total_amount;
        } else {
          $shipping = $table_cost[$i+1];
        }
        break;
      }
    }

    $show_box_weight = ''; 
    if (MODULE_SHIPPING_TABLE_MODE == 'weight') {
      $shipping = $shipping * $shipping_num_boxes;
      // show boxes if weight
      switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
        case (0):
        $show_box_weight = '';
        break;
        case (1):
        $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
        break;
        case (2):
        $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
        default:
        $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
      }
    }

    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
    'cost' => $shipping + (MODULE_SHIPPING_TABLE_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_TABLE_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_TABLE_HANDLING) ) ));

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

    if (!empty($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);

    return $this->quotes;
  }
4 Sep 2024, 6:24 PM
#25
foghead avatar

foghead

New Zenner

Join Date:
Dec 2021
Location:
Tennessee
Posts:
43
Plugin Contributions:
0

Post #25 by foghead

That took care of. I don't have any error log files. Thanks very much for all your help.
You, your knowledge and willing to help us all is greatly appreciated.

4 Sep 2024, 8:05 PM
#26
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #26 by lat9

Foghead:

That took care of. I don't have any error log files. Thanks very much for all your help.
You, your knowledge and willing to help us all is greatly appreciated.
No problems, your post pointed out an issue in the base version of the table.php file!