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)); } } }
function process() { global $order, $currencies; global $store; if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') { switch (MODULE_ORDER_TOTAL_SHIPPING_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_SHIPPING_FREE_SHIPPING_OVER) { $order->info['shipping_method'] = FREE_SHIPPING_TITLE; $order->info['total'] -= $order->info['shipping_cost']; $order->info['shipping_cost'] = 0; } } $module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_')); if (smn_not_null($order->info['shipping_method'])) { if ($GLOBALS[$module]->tax_class > 0) { $shipping_tax = smn_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $shipping_tax_description = smn_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $order->info['tax'] += smn_calculate_tax($order->info['shipping_cost'], $shipping_tax); $order->info['tax_groups']["{$shipping_tax_description}"] += smn_calculate_tax($order->info['shipping_cost'], $shipping_tax); $order->info['total'] += smn_calculate_tax($order->info['shipping_cost'], $shipping_tax); if (DISPLAY_PRICE_WITH_TAX == 'true') { $order->info['shipping_cost'] += smn_calculate_tax($order->info['shipping_cost'], $shipping_tax); } } $this->output[] = array('title' => $order->info['shipping_method'] . ':', 'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']), 'value' => $order->info['shipping_cost']); } }
$authorization_code = substr($string, 20); $sql_data_array = array('customer_id' => $customer_id, 'products_id' => $order->products[$i]['id'], 'purchase_id' => $authorization_code, 'time_entry' => $time_entry, 'time_expire' => (int) $order->products[$i]['time_expire'], 'total_click' => 0, 'total_click_allowed' => (int) $order->products[$i]['total_click_allowed']); smn_db_perform(TABLE_STREAMING_PRODUCTS, $sql_data_array); } $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']); smn_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array); if (DOWNLOAD_ENABLED == 'true' && isset($attributes_values['products_attributes_filename']) && smn_not_null($attributes_values['products_attributes_filename'])) { $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']); smn_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array); } $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name']; } } //------insert customer choosen option eof ---- $total_weight += $order->products[$i]['qty'] * $order->products[$i]['weight']; $total_tax += smn_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty']; $total_cost += $total_products_price; $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; if ($order->products[$i]['products_store_id'] == $store_list[$k]) { $products_ordered_store .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; } } $vendor_query = smn_db_query("select c.*,sd.* from " . TABLE_CUSTOMERS . " c," . TABLE_STORE_MAIN . " s," . TABLE_STORE_DESCRIPTION . " sd where s.store_id=" . $store_list[$k] . " and s.customer_id=c.customers_id and s.store_id=sd.store_id "); $vendor_details = smn_db_fetch_array($vendor_query); $email_order_store = ''; if ($set_member_product == 'true') { $email_order_store .= EMAIL_TEXT_MEMBER_PRODUCT . ' ' . $product_end_date . "\n\n"; } // lets start with the email confirmation $email_order_store .= $vendor_details['store_name'] . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n"; if ($order->info['comments']) {
function get_product_price($product_id) { global $cart, $order; $products_id = smn_get_prid($product_id); // products price $qty = $cart->contents[$product_id]['qty']; $product_query = smn_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . $product_id . "'"); if ($product = smn_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = smn_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $specials_query = smn_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'"); if (smn_db_num_rows($specials_query)) { $specials = smn_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } if ($this->include_tax == 'true') { $total_price += ($products_price + smn_calculate_tax($products_price, $products_tax)) * $qty; } else { $total_price += $products_price * $qty; } // attributes price if (isset($cart->contents[$product_id]['attributes'])) { reset($cart->contents[$product_id]['attributes']); while (list($option, $value) = each($cart->contents[$product_id]['attributes'])) { $attribute_price_query = smn_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'"); $attribute_price = smn_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { if ($this->include_tax == 'true') { $total_price += $qty * ($attribute_price['options_values_price'] + smn_calculate_tax($attribute_price['options_values_price'], $products_tax)); } else { $total_price += $qty * $attribute_price['options_values_price']; } } else { if ($this->include_tax == 'true') { $total_price -= $qty * ($attribute_price['options_values_price'] + smn_calculate_tax($attribute_price['options_values_price'], $products_tax)); } else { $total_price -= $qty * $attribute_price['options_values_price']; } } } } } if ($this->include_shipping == 'true') { $total_price += $order->info['shipping_cost']; } return $total_price; }
function smn_add_tax($price, $tax) { if (DISPLAY_PRICE_WITH_TAX == 'true' && $tax > 0) { return $price + smn_calculate_tax($price, $tax); } else { return $price; } }
function smn_add_tax($price, $tax, $override = false) { if ((DISPLAY_PRICE_WITH_TAX == 'true' || $override == true) && $tax > 0) { return $price + smn_calculate_tax($price, $tax); } else { return $price; } }
function process_button() { global $customer_id, $order, $languages_id, $currencies, $currency, $cart_PayPal_IPN_ID, $shipping, $store; if (MODULE_PAYMENT_PAYPAL_IPN_CURRENCY == 'Selected Currency') { $my_currency = $currency; } else { $my_currency = substr(MODULE_PAYMENT_PAYPAL_IPN_CURRENCY, 5); } if (!in_array($my_currency, array('AUD', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'SGD', 'USD'))) { $my_currency = 'USD'; } $parameters = array(); if (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item' && MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False') { $parameters['cmd'] = '_cart'; $parameters['upload'] = '1'; for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { $item = $i + 1; $tax_value = $order->products[$i]['tax'] / 100 * $order->products[$i]['final_price']; $parameters['item_name_' . $item] = $order->products[$i]['name']; $parameters['amount_' . $item] = number_format($order->products[$i]['final_price'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); $parameters['tax_' . $item] = number_format($tax_value * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); $parameters['quantity_' . $item] = $order->products[$i]['qty']; if ($i == 0) { if (DISPLAY_PRICE_WITH_TAX == 'true') { $shipping_cost = $order->info['shipping_cost']; } else { $module = substr($shipping['id'], 0, strpos($shipping['id'], '_')); $shipping_tax = smn_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $shipping_cost = $order->info['shipping_cost'] + smn_calculate_tax($order->info['shipping_cost'], $shipping_tax); } $parameters['shipping_' . $item] = number_format($shipping_cost * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); } if (isset($order->products[$i]['attributes'])) { for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) { if (DOWNLOAD_ENABLED == 'true') { $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename\n from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n on pa.products_attributes_id=pad.products_attributes_id\n where pa.products_id = '" . $order->products[$i]['id'] . "'\n and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n and pa.options_id = popt.products_options_id\n and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n and pa.options_values_id = poval.products_options_values_id\n and popt.language_id = '" . $languages_id . "'\n and poval.language_id = '" . $languages_id . "'"; $attributes = smn_db_query($attributes_query); } else { $attributes = smn_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'"); } $attributes_values = smn_db_fetch_array($attributes); // Unfortunately PayPal only accepts two attributes per product, so the // third attribute onwards will not be shown at PayPal $parameters['on' . $j . '_' . $item] = $attributes_values['products_options_name']; $parameters['os' . $j . '_' . $item] = $attributes_values['products_options_values_name']; } } } $parameters['num_cart_items'] = $item; if (MOVE_TAX_TO_TOTAL_AMOUNT == 'True') { // PandA.nl move tax to total amount $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); } else { // default $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); } } else { $parameters['cmd'] = '_ext-enter'; $parameters['redirect_cmd'] = '_xclick'; $parameters['item_name'] = STORE_NAME; $parameters['shipping'] = '0'; if (MOVE_TAX_TO_TOTAL_AMOUNT == 'True') { // PandA.nl move tax to total amount $parameters['amount'] = number_format($order->info['total'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); } else { // default $parameters['amount'] = number_format(($order->info['total'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)); } } // billing information fix by gravyface // for pre-populating the fiels if customer has no PayPal account // only works if force shipping address is set to FALSE $state_abbr = smn_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']); $name = $order->delivery['firstname'] . ' ' . $order->delivery['lastname']; $parameters['business'] = MODULE_PAYMENT_PAYPAL_IPN_ID; // let's check what has been defined in the shop admin for the shipping address if (MODULE_PAYMENT_PAYPAL_IPN_SHIPPING == 'True') { // all that matters is that we send the variables // what they contain is irrelevant as PayPal overwrites it with the customer's confirmed PayPal address // so what we send is probably not what we'll get back $parameters['no_shipping'] = '2'; $parameters['address_name'] = $name; $parameters['address_street'] = $order->delivery['street_address']; $parameters['address_city'] = $order->delivery['city']; $parameters['address_zip'] = $order->delivery['postcode']; $parameters['address_state'] = $state_abbr; $parameters['address_country_code'] = $order->delivery['country']['iso_code_2']; $parameters['address_country'] = $order->delivery['country']['title']; $parameters['payer_email'] = $order->customer['email_address']; } else { $parameters['no_shipping'] = '1'; $parameters['H_PhoneNumber'] = $order->customer['telephone']; $parameters['first_name'] = $order->delivery['firstname']; $parameters['last_name'] = $order->delivery['lastname']; $parameters['address1'] = $order->delivery['street_address']; $parameters['address2'] = $order->delivery['suburb']; $parameters['city'] = $order->delivery['city']; $parameters['zip'] = $order->delivery['postcode']; $parameters['state'] = $state_abbr; $parameters['country'] = $order->delivery['country']['iso_code_2']; $parameters['email'] = $order->customer['email_address']; } $parameters['currency_code'] = $my_currency; $parameters['invoice'] = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-') + 1); $parameters['custom'] = $customer_id; $parameters['no_note'] = '1'; $parameters['notify_url'] = smn_href_link('ext/modules/payment/paypal_ipn/ipn.php', '', 'NONSSL', false, false); $parameters['cbt'] = CONFIRMATION_BUTTON_TEXT; $parameters['return'] = smn_href_link(FILENAME_CHECKOUT_PROCESS, 'ID=' . $store->get_store_id(), 'NONSSL'); $parameters['cancel_return'] = smn_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'NONSSL'); $parameters['bn'] = $this->identifier; $parameters['lc'] = $order->customer['country']['iso_code_2']; if (smn_not_null(MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE)) { $parameters['page_style'] = MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE; } if (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'True') { $parameters['cert_id'] = MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID; $random_string = rand(100000, 999999) . '-' . $customer_id . '-'; $data = ''; while (list($key, $value) = each($parameters)) { $data .= $key . '=' . $value . "\n"; } $fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', 'w'); fwrite($fp, $data); fclose($fp); unset($data); if (function_exists('openssl_pkcs7_sign') && function_exists('openssl_pkcs7_encrypt')) { openssl_pkcs7_sign(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY), file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY); unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt'); // remove headers from the signature $signed = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt'); $signed = explode("\n\n", $signed); $signed = base64_decode($signed[1]); $fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', 'w'); fwrite($fp, $signed); fclose($fp); unset($signed); openssl_pkcs7_encrypt(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY); unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt'); // remove headers from the encrypted result $data = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt'); $data = explode("\n\n", $data); $data = '-----BEGIN PKCS7-----' . "\n" . $data[1] . "\n" . '-----END PKCS7-----'; unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt'); } else { exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -sign -in ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt -signer ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY . ' -inkey ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY . ' -outform der -nodetach -binary > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt'); unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt'); exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -encrypt -des3 -binary -outform pem ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY . ' < ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt'); unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt'); $fh = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', 'rb'); $data = fread($fh, filesize(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt')); fclose($fh); unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt'); } $process_button_string = smn_draw_hidden_field('cmd', '_s-xclick') . smn_draw_hidden_field('encrypted', $data); unset($data); } else { while (list($key, $value) = each($parameters)) { echo smn_draw_hidden_field($key, $value); } } return $process_button_string; }