function process()
 {
     global $order, $currencies;
     if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') {
         switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == $store->get_store_country()) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != $store->get_store_country()) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         if ($pass == true && $order->info['total'] - $order->info['shipping_cost'] < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) {
             $tax = smn_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $tax_description = smn_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $order->info['tax'] += smn_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
             $order->info['tax_groups']["{$tax_description}"] += smn_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
             $order->info['total'] += MODULE_ORDER_TOTAL_LOWORDERFEE_FEE + smn_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
             $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format(smn_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax), true, $order->info['currency'], $order->info['currency_value']), 'value' => smn_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax));
         }
     }
 }
Example #2
0
 function display_price($products_price, $products_tax, $quantity = 1, $currency_type = DEFAULT_CURRENCY)
 {
     return $this->format(smn_add_tax($products_price, $products_tax) * $quantity);
 }
<?php 
                    if ($n > 1 || $n2 > 1) {
                        ?>
                    <td class="main"><?php 
                        echo $currencies->format(smn_add_tax($quotes[$i]['methods'][$j]['cost'], isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0));
                        ?>
</td>
                    <td class="main" align="right"><?php 
                        echo smn_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked);
                        ?>
</td>
<?php 
                    } else {
                        ?>
                    <td class="main" align="right" colspan="2"><?php 
                        echo $currencies->format(smn_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . smn_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']);
                        ?>
</td>
<?php 
                    }
                    ?>
                    <td width="10"><?php 
                    echo smn_draw_separator('pixel_trans.gif', '10', '1');
                    ?>
</td>
                  </tr>
<?php 
                    $radio_buttons++;
                }
            }
            ?>
    smn_db_perform(TABLE_ORDERS_TRACKING, $sql_data_array);
    $order_total_modules->apply_credit();
} else {
    $orders_invoice_id = '';
    $store_list = $cart->get_store_list();
    for ($k = 0; $k < sizeof($store_list); $k++) {
        $sql_data_array = array('store_id' => $store_list[$k], 'customers_id' => $customer_id, 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_company' => $order->customer['company'], 'customers_street_address' => $order->customer['street_address'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 'billing_company' => $order->billing['company'], 'billing_street_address' => $order->billing['street_address'], 'billing_city' => $order->billing['city'], 'billing_postcode' => $order->billing['postcode'], 'billing_state' => $order->billing['state'], 'billing_country' => $order->billing['country']['title'], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], 'cc_type' => $order->info['cc_type'], 'cc_owner' => $order->info['cc_owner'], 'cc_number' => $order->info['cc_number'], 'cc_expires' => $order->info['cc_expires'], 'date_purchased' => 'now()', 'last_modified' => 'now()', 'orders_status' => $order->info['order_status'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value']);
        smn_db_perform(TABLE_ORDERS, $sql_data_array);
        $insert_id = smn_db_insert_id();
        $sql_data_array = array('orders_invoice_id' => $orders_invoice_id, 'orders_id' => $insert_id);
        smn_db_perform(TABLE_ORDERS_INVOICE, $sql_data_array);
        $orders_invoice_id = smn_db_insert_id();
        $subtotal_store = '';
        for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
            if ($order->products[$i]['products_store_id'] == $store_list[$k]) {
                $shown_price = smn_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'];
                $subtotal_store += $shown_price;
                $products_tax_store = $order->products[$i]['tax'];
                $products_tax_description_store = $order->products[$i]['tax_description'];
                if (DISPLAY_PRICE_WITH_TAX == 'true') {
                    $tax_store += $shown_price - $shown_price / ($products_tax_store < 10 ? "1.0" . str_replace('.', '', $products_tax_store) : "1." . str_replace('.', '', $products_tax_store));
                } else {
                    $tax_store += $products_tax_store / 100 * $shown_price;
                }
            }
        }
        $shipping_charge_store = $order->info_store[$store_list[$k]]['shipping_cost'];
        if (DISPLAY_PRICE_WITH_TAX == 'true') {
            $total_store = $subtotal_store + $shipping_charge_store;
        } else {
            $total_store = $subtotal_store + $tax_store + $shipping_charge_store;
Example #5
0
</td>
            <td class="dataTableHeadingContent" align="right"><?php 
    echo TABLE_HEADING_TOTAL_INCLUDING_TAX;
    ?>
</td>
          </tr>
        <?php 
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
        echo '      <tr class="dataTableRow">' . "\n" . '        <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" . '        <td class="dataTableContent" valign="top">' . $order->products[$i]['name'] . '<br>';
        if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0) {
            for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
                echo '<nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i><br></small></nobr>';
            }
        }
        echo '        </td>' . "\n" . '        <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n";
        echo '        <td class="dataTableContent" align="right" valign="top">' . smn_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" . '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" . '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" . '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(smn_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
        echo '      </tr>' . "\n";
    }
    ?>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="right" colspan="7"><table border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <?php 
    for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
        echo '          <tr>' . "\n" . '            <td align="right" class="smallText">' . $order->totals[$i]['title'] . '</td>' . "\n" . '            <td align="right" class="smallText">' . $order->totals[$i]['text'] . '</td>' . "\n" . '          </tr>' . "\n";
    }
 function calculate($store = '')
 {
     $this->total_virtual = 0;
     $this->total = 0;
     $this->weight = 0;
     if (!is_array($this->contents)) {
         return 0;
     }
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $qty = $this->contents[$products_id]['qty'];
         // products price
         $product_query = smn_db_query("select products_model, products_tax_class_id, products_price, store_id, products_price, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "' LIMIT 1");
         if ($product = smn_db_fetch_array($product_query)) {
             $products_price = $product['products_price'];
             //SW Fix 9-17-2007 : Consider Special Price
             $products_tax = smn_get_tax_rate($product['products_tax_class_id']);
             $no_count = 1;
             $products_weight = $product['products_weight'];
             //SW Fix 10-1-2007 : Shipping Weight Fix
             $products_store_id = $product['store_id'];
             //SW Fix 10-1-2007 : Shipping Weight Fix
             if (ereg('^GIFT', $gv_result['products_model'])) {
                 $no_count = 0;
             }
             $specials_query = smn_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int) $products_id . "' and status = '1' and store_id = '" . (int) $product['store_id'] . "' LIMIT 1");
             if (smn_db_num_rows($specials_query)) {
                 $specials = smn_db_fetch_array($specials_query);
                 $products_price = $specials['specials_new_products_price'];
             }
             if (isset($store) && $store != '') {
                 if ($products_store_id == $store) {
                     $this->total_virtual += smn_add_tax($products_price, $products_tax) * $qty * $no_count;
                     //SW Fix 9-17-2007 : Consider Special Price
                     $this->weight_virtual += $qty * $products_weight * $no_count;
                     $this->total += smn_add_tax($products_price, $products_tax) * $qty;
                     //SW Fix 9-17-2007 : Consider Special Price
                     $this->weight += $qty * $products_weight;
                     //SW Fix 10-1-2007 : Shipping Weight Fix
                 }
             } else {
                 $this->total_virtual += smn_add_tax($products_price, $products_tax) * $qty * $no_count;
                 //SW Fix 9-17-2007 : Consider Special Price
                 $this->weight_virtual += $qty * $products_weight * $no_count;
                 //SW Fix 10-1-2007 : Shipping Weight Fix
                 $this->total += smn_add_tax($products_price, $products_tax) * $qty;
                 //SW Fix 9-17-2007 : Consider Special Price
                 $this->weight += $qty * $products_weight;
                 //SW Fix 10-1-2007 : Shipping Weight Fix
             }
         }
         // attributes price
         if (isset($this->contents[$products_id]['attributes'])) {
             reset($this->contents[$products_id]['attributes']);
             while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
                 $attribute_price_query = smn_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int) $products_id . "' and options_id = '" . (int) $option . "' and store_id = '" . $products_store_id . "' and options_values_id = '" . (int) $value . "' LIMIT 1");
                 $attribute_price = smn_db_fetch_array($attribute_price_query);
                 if ($attribute_price['price_prefix'] == '+') {
                     $this->total += $qty * smn_add_tax($attribute_price['options_values_price'], $products_tax);
                 } else {
                     $this->total -= $qty * smn_add_tax($attribute_price['options_values_price'], $products_tax);
                 }
             }
         }
     }
 }
 function getNext()
 {
     switch ($this->mode) {
         // yearly
         case '1':
             $sd = $this->actDate;
             $ed = mktime(0, 0, 0, date("m", $sd), date("d", $sd), date("Y", $sd) + 1);
             break;
             // monthly
         // monthly
         case '2':
             $sd = $this->actDate;
             $ed = mktime(0, 0, 0, date("m", $sd) + 1, 1, date("Y", $sd));
             break;
             // weekly
         // weekly
         case '3':
             $sd = $this->actDate;
             $ed = mktime(0, 0, 0, date("m", $sd), date("d", $sd) + 7, date("Y", $sd));
             break;
             // daily
         // daily
         case '4':
             $sd = $this->actDate;
             $ed = mktime(0, 0, 0, date("m", $sd), date("d", $sd) + 1, date("Y", $sd));
             break;
     }
     if ($ed > $this->endDate) {
         $ed = $this->endDate;
     }
     $filterString = "";
     if ($this->statusFilter > 0) {
         $filterString .= " AND o.orders_status = " . $this->statusFilter . " ";
     }
     $rqOrders = smn_db_query($this->queryOrderCnt . " WHERE o.date_purchased >= '" . smn_db_input(date("Y-m-d\\TH:i:s", $sd)) . "' AND o.date_purchased < '" . smn_db_input(date("Y-m-d\\TH:i:s", $ed)) . "'" . $filterString);
     $order = smn_db_fetch_array($rqOrders);
     $rqShipping = smn_db_query($this->queryShipping . " AND o.date_purchased >= '" . smn_db_input(date("Y-m-d\\TH:i:s", $sd)) . "' AND o.date_purchased < '" . smn_db_input(date("Y-m-d\\TH:i:s", $ed)) . "'" . $filterString);
     $shipping = smn_db_fetch_array($rqShipping);
     $rqItems = smn_db_query($this->queryItemCnt . " AND o.date_purchased >= '" . smn_db_input(date("Y-m-d\\TH:i:s", $sd)) . "' AND o.date_purchased < '" . smn_db_input(date("Y-m-d\\TH:i:s", $ed)) . "'" . $filterString . " group by pid " . $this->sortString);
     // return the values
     $this->actDate = $ed;
     $this->showDate = $sd;
     $this->showDateEnd = $ed - 60 * 60 * 24;
     // execute the query
     $cnt = 0;
     $itemTot = 0;
     $sumTot = 0;
     while ($resp[$cnt] = smn_db_fetch_array($rqItems)) {
         // to avoid rounding differences round for every quantum
         // multiply with the number of items afterwords.
         $price = $resp[$cnt]['psum'] / $resp[$cnt]['pquant'];
         // products_attributes
         // are there any attributes for this order_id ?
         $queryAttr = "select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = " . $resp[$cnt]['orders_id'] . " AND orders_products_id = " . $resp[$cnt]['orders_products_id'];
         $attrItems = smn_db_query($queryAttr);
         $i = 0;
         while ($attr[$i] = smn_db_fetch_array($attrItems)) {
             $i++;
         }
         // values per date
         if ($i > 0) {
             $price2 = 0;
             $price3 = 0;
             $optionText = "";
             for ($j = 0; $j < $i; $j++) {
                 if ($attr[$j]['price_prefix'] == "-") {
                     $price2 += -1 * $attr[$j]['options_values_price'];
                     $price3 = -1 * $attr[$j]['options_values_price'];
                     $prefix = "-";
                 } else {
                     $price2 += $attr[$j]['options_values_price'];
                     $price3 = $attr[$j]['options_values_price'];
                     $prefix = "+";
                 }
                 if ($j == 0) {
                     $optionText .= $attr[$j]['products_options'] . ": " . $attr[$j]['products_options_values'];
                 } else {
                     $optionText .= ", " . $attr[$j]['products_options'] . ": " . $attr[$j]['products_options_values'];
                 }
                 if ($price3 != 0) {
                     $optionText .= " [" . $prefix . smn_add_tax($price3, $resp[$cnt]['ptax']) . "]";
                 }
             }
             $resp[$cnt]['psum'] = $resp[$cnt]['pquant'] * smn_add_tax($price + $price2, $resp[$cnt]['ptax']);
             // overwrite pname
             $resp[$cnt]['pname'] = $resp[$cnt]['pname'] . " (" . $optionText . ")";
         } else {
             $resp[$cnt]['psum'] = $resp[$cnt]['pquant'] * smn_add_tax($price, $resp[$cnt]['ptax']);
         }
         $resp[$cnt]['order'] = $order['order_cnt'];
         $resp[$cnt]['shipping'] = $shipping['shipping'];
         // values per date and item
         $sumTot += $resp[$cnt]['psum'];
         $itemTot += $resp[$cnt]['pquant'];
         // add totsum and totitem until current row
         $resp[$cnt]['totsum'] = $sumTot;
         $resp[$cnt]['totitem'] = $itemTot;
         $cnt++;
     }
     return $resp;
 }
</b></td>
                  </tr>
<?php 
}
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
    echo '          <tr>' . "\n" . '            <td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" . '            <td class="main" valign="top">' . $order->products[$i]['name'];
    if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0) {
        for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
            echo '<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
        }
    }
    echo '</td>' . "\n";
    if (sizeof($order->info['tax_groups']) > 1) {
        echo '            <td class="main" valign="top" align="right">' . smn_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n";
    }
    echo '            <td class="main" align="right" valign="top">' . $currencies->format(smn_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" . '          </tr>' . "\n";
}
?>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php 
echo smn_draw_separator('pixel_trans.gif', '100%', '10');
?>
</td>
      </tr>
      <tr>
 function calculate($store = '')
 {
     $this->total = 0;
     $this->weight = 0;
     if (!is_array($this->contents)) {
         return 0;
     }
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $qty = $this->contents[$products_id]['qty'];
         // products price
         $product_query = smn_db_query("select products_id, store_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'");
         if ($product = smn_db_fetch_array($product_query)) {
             $products_id = smn_get_uprid($products_id, $attributes);
             $products_store_id = $product['store_id'];
             $products_tax = smn_get_tax_rate($product['products_tax_class_id']);
             $products_price = $product['products_price'];
             $products_weight = $product['products_weight'];
             $specials_query = smn_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int) $prid . "' and status = '1' and store_id = '" . $products_store_id . "'");
             if (smn_db_num_rows($specials_query)) {
                 $specials = smn_db_fetch_array($specials_query);
                 $products_price = $specials['specials_new_products_price'];
             }
             if (isset($store) && $store != '') {
                 if ($products_store_id == $store) {
                     $this->total += smn_add_tax($products_price, $products_tax) * $qty;
                     $this->weight += $qty * $products_weight;
                 }
             } else {
                 $this->total += smn_add_tax($products_price, $products_tax) * $qty;
                 $this->weight += $qty * $products_weight;
             }
         }
         // attributes price
         if (isset($this->contents[$products_id]['attributes'])) {
             reset($this->contents[$products_id]['attributes']);
             while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
                 $attribute_price_query = smn_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int) $prid . "' and options_id = '" . (int) $option . "' and store_id = '" . $products_store_id . "' and options_values_id = '" . (int) $value . "'");
                 $attribute_price = smn_db_fetch_array($attribute_price_query);
                 if ($attribute_price['price_prefix'] == '+') {
                     $this->total += $qty * smn_add_tax($attribute_price['options_values_price'], $products_tax);
                 } else {
                     $this->total -= $qty * smn_add_tax($attribute_price['options_values_price'], $products_tax);
                 }
             }
         }
     }
 }
Example #10
0
 function calculate_price($products_price, $products_tax, $quantity = 1)
 {
     global $currency;
     return smn_round(smn_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity;
 }