Results 1 to 3 of 3
  1. #1
    Join Date
    May 2008
    Posts
    1
    Plugin Contributions
    0

    Default "Table Rate - Add Percentage" Problem

    Hello to all,

    I'm having some trouble with this shipping module. Here's how I want to setup shipping costs, based on the total amount of the order:

    • order < 70 EUR : 10 EUR shipping costs
    • 70 EUR < order < 500 EUR : 5% of total order shipping costs
    • order > 500 EUR : free shipping


    I have succesfully modified the contents of the /includes/modules/shipping/table.php file. The code was (starting from line 105):

    PHP Code:
      $table_cost split("[:,]" MODULE_SHIPPING_TABLE_COST);
      
    $size sizeof($table_cost);
      for (
    $i=0$n=$size$i<$n$i+=2) {
       if (
    $order_total <= $table_cost[$i]) {
        
    $shipping $table_cost[$i+1];
        break;
       }
      } 
    And now the code is:

    PHP Code:
      $table_cost split("[:,]"MODULE_SHIPPING_TABLE_COST);
      
    $size sizeof($table_cost);
      for(
    $i=0$n=$size$i<$n$i+=2) {
        if(
    $order_total <= $table_cost[$i]) {
          
    $pos strpos($table_cost[$i+1], '%');
          if(
    $pos === false) {
            
    $shipping $table_cost[$i+1];
          }
          else {
            
    $shipping_cost_temp split("%"$table_cost[$i+1]);
            
    $shipping $order_total $shipping_cost_temp[0] / 100;
            break;
          }
        }
      } 
    The problem is that every value I input in the table is taken as a percentage of the total order. For instance, if the table is:

    Code:
    70.00:10.00,499.99:5%
    For orders under 70 EUR I don't get 10 EUR of shipping costs, but 10% of the total order. I'm no PHP expert but as far as I see, the code above should already check if the value has the percentage sign (%) in it. So the value should be taken as a percentage of the total order only if it has the % in it.

    Any clue or suggestion? This is really frustrating me... Thanks a lot, any help is extremely appreciated!

  2. #2
    Join Date
    Jul 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: "Table Rate - Add Percentage" Problem

    Did you intend to have 3 equal signs in the line "if($pos === false) { "? My guess is that condition can never be true.

  3. #3
    Join Date
    Feb 2005
    Posts
    246
    Plugin Contributions
    0

    Default Re: "Table Rate - Add Percentage" Problem fixed error in above code

    I fixed the triple equal sign, and added a "break;" in line 8 of this code. (line 112 if placed at 105 as mentioned.)

    PHP Code:
       $table_cost split("[:,]"MODULE_SHIPPING_TABLE_COST);
       
    $size sizeof($table_cost);
       for(
    $i=0$n=$size$i<$n$i+=2) {
         if(
    $order_total <= $table_cost[$i]) {
           
    $pos strpos($table_cost[$i+1], '%');
           if(
    $pos == false) {
             
    $shipping $table_cost[$i+1];
             break;
           }
           else {
             
    $shipping_cost_temp split("%"$table_cost[$i+1]);
             
    $shipping $order_total $shipping_cost_temp[0] / 100;
             break;
           }
         }
      } 
    It worked for me.
    Thanks!

 

 

Similar Threads

  1. Using "table" shipping but need one category to be "Flat Rate"
    By GTHENRY in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 27 Apr 2011, 08:35 PM
  2. How do I change "Table Rate (Best Way)" to "Ground Shipping"?
    By John Vieth in forum General Questions
    Replies: 4
    Last Post: 1 Jul 2010, 10:37 PM
  3. Table Rate: Replace "0.00" With "FREE"?
    By msmith29063 in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 1 Dec 2008, 04:50 PM
  4. add percentage to table rate
    By CnTGifts in forum Addon Shipping Modules
    Replies: 0
    Last Post: 3 Jul 2007, 04:53 PM
  5. Add "shipping" next to "table rate" on invoice
    By mrmeech in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 12 Jan 2007, 07:54 AM

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