Zen Cart Logo
Forums / Managing Customers and Orders / Low order fee by manufacturer?

Low order fee by manufacturer?

Views: 7,643

Results 1 to 14 of 14
7 Sep 2014, 4:46 PM
#1
cabinetguy avatar

cabinetguy

Zen Follower

Join Date:
Feb 2008
Location:
Tx gulf coast
Posts:
126
Plugin Contributions:
0

Low order fee by manufacturer?

Can this section of the ot_loworderfee.php be edited to reflect manufacturer instead of locality?

if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') {
switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
case 'national':
if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
case 'international':
if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
case 'both':
$pass = true; break;
default:
$pass = false; break;
}

What would I need to do to have options for either manufacturer or category?

Thanks..

7 Sep 2014, 4:59 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Low order fee by manufacturer?

Can you give an example of what you want to do?

Is this just for 1 particular manufacturer? Or is it for many?

Is this just for 1 category? Or is it for many?

On the category/categories, would this be the master_categories_id? Or, would you want any Product in a Category with subcategories?

7 Sep 2014, 5:03 PM
#3
cabinetguy avatar

cabinetguy

Zen Follower

Join Date:
Feb 2008
Location:
Tx gulf coast
Posts:
126
Plugin Contributions:
0

Re: Low order fee by manufacturer?

Thanks Ajeh...

I sell a product, cabinet doors and drawer fronts, offered by three or more manufacturers.... at least two of them have a minimum order fee to me which I must pass on. So, there would most likely need to be something like a 'tick box' in the manufacturer information that designates this as such.

Let me know if other info is needed.

TIA

7 Sep 2014, 6:06 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Low order fee by manufacturer?

If you were able to calculate the Total amount for the combined total of the 1-3 manufacturers products in the cart, would that be able to be used for the low order fee?

7 Sep 2014, 6:16 PM
#5
cabinetguy avatar

cabinetguy

Zen Follower

Join Date:
Feb 2008
Location:
Tx gulf coast
Posts:
126
Plugin Contributions:
0

Re: Low order fee by manufacturer?

Ajeh, the low order by mfg would have to stand alone for each mfg. So, if mfg "a" has minimum of $40, then it must be tested as a total for that unique mfg. Same for mfg "b", "c", etc...this allows for as many low order fees as necessary based on the separate mfg's. Normally, a customer does not "cross the mfg lines" when buying products, but it is a remote possibility. I only have two mfgs at this time that even have a low order fee...so I don't see this as too big of an issue, going forward...

tia

7 Sep 2014, 9:04 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Low order fee by manufacturer?

You can do this by editing the Order Total module:
/includes/modules/order_total/ot_loworderfee.php

and replace the whole function process with the new code:

    function process() {
      global $order, $currencies;

      $chk_manufacturers_1_id = 3; // manufacturers_id 3
      $chk_manufacturers_1_total = 0;
      $chk_manufacturers_1_min = 30.00;
      $chk_manufacturers_1_extra = 3.00;

      $chk_manufacturers_2_id = 4; // manufacturers_id 4
      $chk_manufacturers_2_total = 0;
      $chk_manufacturers_2_min = 40.00;
      $chk_manufacturers_2_extra = 4.00;

      $products = $_SESSION['cart']->get_products();
//echo '<pre>'; echo print_r($products); echo '</pre>';
      for ($i=0, $n=sizeof($products); $i<$n; $i++) {
        $product_id = $products[$i]['id'];
        $ppe = $products[$i]['final_price'];
        $ppt = $ppe * $products[$i]['quantity'];
        $productsPriceTotal = $ppt + $products[$i]['onetime_charges'];
//echo 'product_id: ' . $product_id . ' $ppt: ' . $ppt . ' qty: ' . $products[$i]['quantity'] . ' $productsPriceTotal: ' . $productsPriceTotal . '<br>';
        if (zen_products_lookup($product_id, 'manufacturers_id') == $chk_manufacturers_1_id && (int)$product_id == (int)$products[$i]['id']) {
          $chk_manufacturers_1_total += $productsPriceTotal;
//echo '$chk_manufacturers_1_id: ' . $chk_manufacturers_1_id . ' $product_id: ' . $product_id . ' $chk_manufacturers_1_total: ' . $productsPriceTotal . '<br>';
        }
        if (zen_products_lookup($product_id, 'manufacturers_id') == $chk_manufacturers_2_id && (int)$product_id == (int)$products[$i]['id']) {
          $chk_manufacturers_2_total += $productsPriceTotal;
//echo '$chk_manufacturers_2_id: ' . $chk_manufacturers_2_id . ' $product_id: ' . $product_id . ' $chk_manufacturers_2_total: ' . $productsPriceTotal . '<br>';
        }
      } // end FOR loop
        $extra_fee = ($chk_manufacturers_1_total < $chk_manufacturers_1_min ? $chk_manufacturers_1_extra : 0) + ($chk_manufacturers_2_total < $chk_manufacturers_2_min ? $chk_manufacturers_2_extra : 0);

        if ($extra_fee > 0) {
          $tax_address = zen_get_tax_locations();
          $tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);
          $tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);

// calculate from flat fee or percentage
          $low_order_fee = $extra_fee;

          $order->info['tax'] += zen_calculate_tax($low_order_fee, $tax);
          $order->info['tax_groups']["$tax_description"] += zen_calculate_tax($low_order_fee, $tax);
          $order->info['total'] += $low_order_fee + zen_calculate_tax($low_order_fee, $tax);
          if (DISPLAY_PRICE_WITH_TAX == 'true') {
            $low_order_fee += zen_calculate_tax($low_order_fee, $tax);
          }

          $this->output[] = array('title' => $this->title . ':',
                                  'text' => $currencies->format($low_order_fee, true, $order->info['currency'], $order->info['currency_value']),
                                  'value' => $low_order_fee);
      }
    }

The set the variables to match your manufacturers_id, minimum, extra fee for each set, example:
** $chk_manufacturers_1_id = 3; // manufacturers_id 3
$chk_manufacturers_1_total = 0;
$chk_manufacturers_1_min = 30.00;
$chk_manufacturers_1_extra = 3.00;
**
This would be manufacturers_id 3, minimum $30.00 and extra fee $3.00 ...

7 Sep 2014, 9:25 PM
#7
cabinetguy avatar

cabinetguy

Zen Follower

Join Date:
Feb 2008
Location:
Tx gulf coast
Posts:
126
Plugin Contributions:
0

Re: Low order fee by manufacturer?

Ajeh,
This looks good right up to checkout...

  1. I added the info for the mfg name variables... :
    function process() {
    global $order, $currencies;

    $chk_manufacturers_1_id = 38; // manufacturers_id 38
    $chk_manufacturers_1_total = 0;
    $chk_manufacturers_1_min = 40.00;
    $chk_manufacturers_1_extra = 15.00;

    $chk_manufacturers_2_id = 156; // manufacturers_id 156
    $chk_manufacturers_2_total = 0;
    $chk_manufacturers_2_min = 40.00;
    $chk_manufacturers_2_extra = 15.00;

The only problem was that it adds the manufacturers_extra for both...whether there is product or not in the cart.
If I remove one of the above variable sets, everything is peachy....

suggestion to prevent the adding of both, product or not?

Thanks, you are helping me immensely.

Keith

8 Sep 2014, 12:17 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Low order fee by manufacturer?

See if changing the calculation for the extra fee works better with:

        $extra_fee = ($chk_manufacturers_1_total> 0 && $chk_manufacturers_1_total < $chk_manufacturers_1_min ? $chk_manufacturers_1_extra : 0) + ($chk_manufacturers_2_total > 0 && $chk_manufacturers_2_total < $chk_manufacturers_2_min ? $chk_manufacturers_2_extra : 0);
8 Sep 2014, 1:50 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Low order fee by manufacturer?

See if this works better for you:

        $extra_fee = ($chk_manufacturers_1_total > 0 && $chk_manufacturers_1_total < $chk_manufacturers_1_min ? $chk_manufacturers_1_extra : 0) + ($chk_manufacturers_2_total > 0 && $chk_manufacturers_2_total < $chk_manufacturers_2_min ? $chk_manufacturers_2_extra : 0);
8 Sep 2014, 1:52 PM
#10
cabinetguy avatar

cabinetguy

Zen Follower

Join Date:
Feb 2008
Location:
Tx gulf coast
Posts:
126
Plugin Contributions:
0

Re: Low order fee by manufacturer?

Ajeh,

This seemed to do the trick....prior to receiving this, all of the orders processed for the rest of the day had a small order fee attached, whether they had qualifying product or not. I spent some time this morning processing a bunch of refunds.

I appreciate your assistance...I will monitor the fix throughout the day and see if any other issues pop up.

Thanks again for your great help.

Keith

8 Sep 2014, 2:07 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Low order fee by manufacturer?

You are most welcome ... thanks for the update that this is working for you ... :smile:

12 Oct 2018, 3:16 AM
#12
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
969
Plugin Contributions:
0

Re: Low order fee by manufacturer?

how can i set this to look at another column in the products table, i am able to set up products by the way they ship. i have Shipper as a column and want to look at that to determin low order fee.
would i change, $chk_manufacturers_1_id = 2; // Crain Cutter
to $chk_Shipper_1_id = Crain; // Crain Cutter

13 Oct 2018, 10:49 PM
#13
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
969
Plugin Contributions:
0

Re: Low order fee by manufacturer?

i changed all instances of manufacturers to Shipper and changed the id number to my value and all seems to be working.

6 Mar 2024, 3:56 PM
#14
giancalr avatar

giancalr

Zen Follower

Join Date:
Jul 2010
Location:
L'Aquila
Posts:
113
Plugin Contributions:
1

Re: Low order fee by manufacturer?

Good Afternoon, I was looking for something exactly like this, it is possible to see the complete modified file working, since I tried to make the indicated modification, but it doesn't work for me, how did you also manage the module configuration tables? Thank you