Beispiel #1
0
 /**
  * Insert Order
  *
  * @access public
  * @return boolean
  */
 public function insert_order($order_status = NULL)
 {
     //order data
     $data = array('customers_id' => $this->customer->get_id(), 'customers_name' => $this->customer->get_name(), 'customers_company' => '', 'customers_street_address' => '', 'customers_suburb' => '', 'customers_city' => '', 'customers_postcode' => '', 'customers_state' => '', 'customers_state_code' => '', 'customers_country_iso2' => '', 'customers_country_iso3' => '', 'customers_telephone' => '', 'customers_email_address' => $this->customer->get_email_address(), 'customers_comment' => $this->session->userdata('payment_comments'), 'customers_address_format' => '', 'customers_ip_address' => $this->input->ip_address(), 'delivery_name' => $this->shopping_cart->get_shipping_address('firstname') . ' ' . $this->shopping_cart->get_shipping_address('lastname'), 'delivery_company' => $this->shopping_cart->get_shipping_address('company'), 'delivery_street_address' => $this->shopping_cart->get_shipping_address('street_address'), 'delivery_suburb' => $this->shopping_cart->get_shipping_address('suburb'), 'delivery_city' => $this->shopping_cart->get_shipping_address('city'), 'delivery_postcode' => $this->shopping_cart->get_shipping_address('postcode'), 'delivery_state' => $this->shopping_cart->get_shipping_address('state'), 'delivery_zone_id' => $this->shopping_cart->get_shipping_address('zone_id'), 'delivery_state_code' => $this->shopping_cart->get_shipping_address('zone_code'), 'delivery_country_id' => $this->shopping_cart->get_shipping_address('country_id'), 'delivery_country' => $this->shopping_cart->get_shipping_address('country_title'), 'delivery_country_iso2' => $this->shopping_cart->get_shipping_address('country_iso_code_2'), 'delivery_country_iso3' => $this->shopping_cart->get_shipping_address('country_iso_code_3'), 'delivery_address_format' => $this->shopping_cart->get_shipping_address('format'), 'delivery_telephone' => $this->shopping_cart->get_shipping_address('telephone_number'), 'billing_name' => $this->shopping_cart->get_billing_address('firstname') . ' ' . $this->shopping_cart->get_billing_address('lastname'), 'billing_company' => $this->shopping_cart->get_billing_address('company'), 'billing_street_address' => $this->shopping_cart->get_billing_address('street_address'), 'billing_suburb' => $this->shopping_cart->get_billing_address('suburb'), 'billing_city' => $this->shopping_cart->get_billing_address('city'), 'billing_postcode' => $this->shopping_cart->get_billing_address('postcode'), 'billing_state' => $this->shopping_cart->get_billing_address('state'), 'billing_zone_id' => $this->shopping_cart->get_billing_address('zone_id'), 'billing_state_code' => $this->shopping_cart->get_billing_address('zone_code'), 'billing_country_id' => $this->shopping_cart->get_billing_address('country_id'), 'billing_country' => $this->shopping_cart->get_billing_address('country_title'), 'billing_country_iso2' => $this->shopping_cart->get_billing_address('country_iso_code_2'), 'billing_country_iso3' => $this->shopping_cart->get_billing_address('country_iso_code_3'), 'billing_address_format' => $this->shopping_cart->get_billing_address('format'), 'billing_telephone' => $this->shopping_cart->get_billing_address('telephone_number'), 'payment_method' => $this->shopping_cart->get_billing_method('title'), 'payment_module' => $this->shopping_cart->get_billing_method('id'), 'uses_store_credit' => 0, 'store_credit_amount' => 0, 'orders_status' => $order_status === NULL ? config('DEFAULT_ORDERS_STATUS_ID') : $order_status, 'currency' => $this->currencies->get_code(), 'currency_value' => $this->currencies->value($this->currencies->get_code()), 'gift_wrapping' => '0', 'wrapping_message' => '');
     $this->db->insert('orders', $data);
     //get insert id
     $insert_id = $this->db->insert_id();
     //insert order totals
     $order_totals = $this->shopping_cart->get_order_totals();
     foreach ($order_totals as $total) {
         $data = array('orders_id' => $insert_id, 'title' => $total['title'], 'text' => $total['text'], 'value' => $total['value'], 'class' => $total['code'], 'sort_order' => $total['sort_order']);
         $this->db->insert('orders_total', $data);
     }
     //insert comment
     $data = array('orders_id' => $insert_id, 'orders_status_id' => config('DEFAULT_ORDERS_STATUS_ID'), 'customer_notified' => 0, 'comments' => $this->session->userdata('payment_comments'), 'date_added' => date('Y-m-d H:i:s', now()));
     $this->db->insert('orders_status_history', $data);
     //products
     $products = $this->shopping_cart->get_products();
     foreach ($products as $product) {
         $data = array('orders_id' => $insert_id, 'products_id' => get_product_id($product['id']), 'products_type' => $product['type'], 'products_sku' => $product['sku'], 'products_name' => $product['name'], 'products_price' => $product['price'], 'final_price' => $product['final_price'], 'products_tax' => get_tax_rate($product['tax_class_id'], $this->shopping_cart->get_taxing_address('country_id'), $this->shopping_cart->get_taxing_address('zone_id')), 'products_quantity' => $product['quantity']);
         $this->db->insert('orders_products', $data);
         //variants
         $order_products_id = $this->db->insert_id();
         if ($this->shopping_cart->has_variants($product['id'])) {
             foreach ($this->shopping_cart->get_variants($product['id']) as $variants_id => $variants) {
                 $result = $this->db->select('pvg.products_variants_groups_name, pvv.products_variants_values_name')->from('products_variants pv')->join('products_variants_entries pve', 'pv.products_variants_id = pve.products_variants_id', 'inner')->join('products_variants_groups pvg', 'pve.products_variants_groups_id = pvg.products_variants_groups_id', 'inner')->join('products_variants_values pvv', 'pve.products_variants_values_id = pvv.products_variants_values_id', 'inner')->where('pv.products_id', $product['id'])->where('pve.products_variants_groups_id', $variants['groups_id'])->where('pve.products_variants_values_id', $variants['variants_values_id'])->where('pvg.language_id', lang_id())->where('pvv.language_id', lang_id())->get();
                 if ($result->num_rows() > 0) {
                     $row = $result->row_array();
                     $data = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_variants_groups_id' => $variants['groups_id'], 'products_variants_groups' => $row['products_variants_groups_name'], 'products_variants_values_id' => $variants['variants_values_id'], 'products_variants_values' => $row['products_variants_values_name']);
                     $this->db->insert('orders_products_variants', $data);
                 }
             }
         }
     }
     return $insert_id;
 }
Beispiel #2
0
            $option2_price = $food_info["option2_price"];
        }
        $food_quantity = $item["cart_item_quantity"];
        $food_price = $food_info["food_price"];
        $food_total_price = ($food_price + $option1_price + $option2_price) * $food_quantity;
        array_push($grand_total_array, $food_total_price);
        //echo '$ '.number_format($food_total_price,2,".","");
    }
    // end if
    $var_count++;
}
// end while loop
/////////////////// CALCULATE VALUES ////////////////////
$subtotal = array_sum($grand_total_array);
$subtotal = number_format($subtotal, 2, ".", ",");
$tax_rate = get_tax_rate();
$tax_total = $subtotal / 100 * $tax_rate;
$tax_total = number_format($tax_total, 2, ".", ",");
if (isset($_SESSION["cart_tip"])) {
    $tip = clean_input($_SESSION["cart_tip"]);
} else {
    $tip = 0;
}
if ($tip == 0) {
    $tip = "No Tip";
} else {
    $tip = number_format($tip, 2, ".", ",");
}
$grand_total = $subtotal + $tax_total + $tip;
$grand_total = number_format($grand_total, 2, ".", ",");
$_SESSION["Payment_Amount"] = $grand_total;
function create_new_bill_entry($subtotal, $tip, $amount_charged, $time_placed, $placed_by_cust_id, $payment_method, $transaction_type, $transaction_id, $auth_code, $card_type, $card_number, $card_exp_mo, $card_exp_yr, $card_name_first, $card_name_last, $payment_type, $payment_status, $transaction_mode)
{
    global $connection;
    $query = "INSERT INTO history_bill ( ";
    //$query .= "bill_id, "; // AUTO INCREMENT
    $query .= "invoice_number, ";
    $query .= "subtotal, ";
    $query .= "original_subtotal, ";
    $query .= "tax_rate, ";
    $query .= "tax, ";
    $query .= "original_tax, ";
    $query .= "tip, ";
    $query .= "original_tip, ";
    $query .= "grandtotal, ";
    $query .= "amount_charged, ";
    $query .= "original_amount_charged, ";
    $query .= "time_placed, ";
    $query .= "wait_time, ";
    $query .= "placed_by_cust_id, ";
    $query .= "payment_method, ";
    $query .= "transaction_type, ";
    $query .= "transaction_id, ";
    $query .= "auth_code, ";
    $query .= "card_type, ";
    $query .= "card_number, ";
    $query .= "card_exp_mo, ";
    $query .= "card_exp_yr, ";
    $query .= "card_name_first, ";
    $query .= "card_name_last, ";
    $query .= "payment_type, ";
    $query .= "payment_status, ";
    $query .= "transaction_mode, ";
    $query .= "entry_status";
    $query .= " ) VALUES ( ";
    /////////// SETTING UP SOME VARIABLES ///////////
    $tax_rate = get_tax_rate();
    $wait_time = get_current_wait_time();
    $entry_status = "good_standing";
    $invoice_number = generate_next_invoice_number();
    $tax = $subtotal / 100 * $tax_rate;
    $tax = number_format($tax, 2, ".", "");
    //$query .= "bill_id, "; // AUTO INCREMENT
    $query .= "'{$invoice_number}', ";
    $query .= "{$subtotal}, ";
    $query .= "{$subtotal}, ";
    $query .= "{$tax_rate}, ";
    $query .= "{$tax}, ";
    $query .= "{$tax}, ";
    $query .= "{$tip}, ";
    $query .= "{$tip}, ";
    $query .= "{$amount_charged}, ";
    $query .= "{$amount_charged}, ";
    $query .= "{$amount_charged}, ";
    $query .= "'{$time_placed}', ";
    $query .= "{$wait_time}, ";
    $query .= "{$placed_by_cust_id}, ";
    $query .= "'{$payment_method}', ";
    $query .= "'{$transaction_type}', ";
    $query .= "'{$transaction_id}', ";
    $query .= "'{$auth_code}', ";
    $query .= "'{$card_type}', ";
    $query .= "'{$card_number}', ";
    $query .= "'{$card_exp_mo}', ";
    $query .= "'{$card_exp_yr}', ";
    $query .= "'{$card_name_first}', ";
    $query .= "'{$card_name_last}', ";
    $query .= "'{$payment_type}', ";
    $query .= "'{$payment_status}', ";
    $query .= "'{$transaction_mode}', ";
    $query .= "'{$entry_status}' );";
    $result = mysqli_query($connection, $query);
    checkQuery($result);
    return $invoice_number;
}
    //echo '<span class="markProductOutOfStock">' . config('STOCK_MARK_PRODUCT_OUT_OF_STOCK') . '</span>';
    //}
    if (isset($product['variants']) && sizeof($product['variants']) > 0) {
        foreach ($product['variants'] as $variants) {
            echo '<br /><nobr><small>&nbsp;<i> - ' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></small></nobr>';
        }
    }
    ?>
                            	</td>
                            <?php 
    if ($number_of_tax_groups > 1) {
        ?>
								<td valign="top" align="right">
									<?php 
        $shopping_cart = get_shopping_cart();
        echo display_tax_rate_value(get_tax_rate($product['tax_class_id'], $shopping_cart->get_taxing_address('country_id'), $shopping_cart->get_taxing_address('zone_id')));
        ?>
                            <?php 
    }
    ?>
                            	<td align="right" valign="top"><?php 
    echo currencies_display_price($product['final_price'], $product['tax_class_id'], $product['quantity']);
    ?>
</td>
                            </tr>
                            <?php 
}
?>
                        </table>
            
                        <table width="100%" cellspacing="0" cellpadding="2">