Example #1
0
* @subpackage html
* @copyright Copyright (C) 2004-2009 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
require_once CLASSPATH . 'ps_checkout.php';
$ps_checkout = new ps_checkout();
require_once CLASSPATH . 'ps_shipping_method.php';
global $weight_total, $total, $tax_total, $order_tax_details, $discount_factor, $order_total;
/* make sure this is the checkout screen */
if ($cart["idx"] == 0) {
    echo $VM_LANG->_('PHPSHOP_EMPTY_CART');
    $checkout = False;
} else {
    $checkout = True;
    $payment_method_id = vmGet($_REQUEST, "payment_method_id");
    $total = 0;
    // Added for the zone shipping module
    $vars["zone_qty"] = 0;
    $weight_total = 0;
    $weight_subtotal = 0;
    $tax_total = 0;
*
* @version $Id: get_final_confirmation.tpl.php 1443 2008-06-30 18:39:22Z soeren_nb $
* @package VirtueMart
* @subpackage templates
* @copyright Copyright (C) 2007 Soeren Eberhardt. All rights reserved. Edited by Aaron Klick to work with Paypal Pro Express Checkout
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
global $vmLogger;
ps_checkout::show_checkout_bar();
require_once CLASSPATH . "payment/ps_paypal_wpp.cfg.php";
require_once CLASSPATH . "payment/ps_paypal_wpp.cfg2.php";
require_once CLASSPATH . "payment/nvp_include/languages/lang." . PP_WPP_LANGUAGE . ".php";
require_once CLASSPATH . "payment/nvp_include/nvp_functions.php";
require_once CLASSPATH . "payment/nvp_include/nvp_errors.php";
echo $basket_html;
echo '<br />';
$varname = 'PHPSHOP_CHECKOUT_MSG_' . CHECK_OUT_GET_FINAL_CONFIRMATION;
echo '<h5>' . $VM_LANG->_($varname) . '</h5>';
$_SESSION['paypal_ex_request'] = TRUE;
//Get required variables
if (isset($_REQUEST['token'])) {
    $token = $_REQUEST['token'];
    //Try and get our information from paypal
    $nvpRES = NVP_GetExpressCheckout($token);
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
ps_checkout::show_checkout_bar();
echo $basket_html;
echo '<br />';
?>
<div style="width: 100%; align:left;">
	<?php 
// CHECK_OUT_GET_SHIPPING_ADDR
// let the user choose a shipto address
echo ps_checkout::display_address();
?>
<br />
</div>
<div class="sectiontableheader" style="width: 100%; align: left; float: left;"> <?php 
echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_CUST_SHIPPING_LBL');
?>
</div>

<div style="width: 100%; align:left; float:left;">
<?php 
$varname = 'PHPSHOP_CHECKOUT_MSG_' . CHECK_OUT_GET_SHIPPING_ADDR;
echo '<h4>' . $VM_LANG->_($varname) . '</h4>';
?>
</div>
<!-- Customer Ship To -->
        echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_EXPIRE_DATE');
        ?>
</th>
    				  </tr>
    				  <tr> 
      					<td width="13%">
                  <?php 
        $ps_order_change_html->html_change_payment($dbpm->f("payment_method_id"));
        ?>
                </td>
      					<td width="40%"><?php 
        $dbpm->p("order_payment_name");
        ?>
</td>
      					<td width="30%"><?php 
        echo ps_checkout::asterisk_pad($dbaccount->f("account_number"), 4, true);
        if ($dbaccount->f('order_payment_code')) {
            echo '<br/>(' . $VM_LANG->_('VM_ORDER_PAYMENT_CCV_CODE') . ': ' . $dbaccount->f('order_payment_code') . ') ';
        }
        ?>
                </td>
      					<td width="17%"><?php 
        echo $dbpm->f("order_payment_expire") ? vmFormatDate($dbpm->f("order_payment_expire"), '%b-%Y') : '';
        ?>
</td>
    				  </tr> 
    				  <tr class="sectiontableheader"> 
      					<th colspan="4"><?php 
        echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_PAYMENT_LOG_LBL');
        ?>
</th>
Example #5
0
 function NVP_DoDirectPaymentRequest(&$d, $dbbt, $dbst, $order_total, $payment_action, $ordernum, $requireCVV)
 {
     global $vendor_mail, $vendor_currency, $VM_LANG;
     if (isset($_SESSION['ccdata']['order_payment_number'])) {
         $cc_first_digit = substr($_SESSION['ccdata']['order_payment_number'], 0, 1);
         $cc_first_2_digits = substr($_SESSION['ccdata']['order_payment_number'], 0, 2);
         // Figure out the card type.
         switch ($cc_first_digit) {
             case "4":
                 $cc_type = urlencode("Visa");
                 break;
             case "5":
                 $cc_type = urlencode("MasterCard");
                 break;
             case "3":
                 switch ($cc_first_2_digits) {
                     case "34":
                         $cc_type = urlencode("Amex");
                         break;
                     case "37":
                         $cc_type = urlencode("Amex");
                         break;
                     case "30":
                         $cc_type = urlencode("Discover");
                         break;
                     case "36":
                         $cc_type = urlencode("Discover");
                         break;
                     case "38":
                         $cc_type = urlencode("Discover");
                         break;
                     default:
                         return false;
                         break;
                 }
                 break;
             case "6":
                 $cc_type = urlencode("Discover");
                 break;
             default:
                 return false;
                 break;
         }
         //Gather all required data
         //Remove any dashes or spaces in the credit card number
         $tmp_number = str_replace('-', '', $_SESSION['ccdata']['order_payment_number']);
         $tmp_number = str_replace(' ', '', $tmp_number);
         $cc_number = urlencode($tmp_number);
         if (isset($_SESSION['ccdata']['credit_card_code'])) {
             $cc_cvv2 = urlencode($_SESSION['ccdata']['credit_card_code']);
         } else {
             if ($requireCVV == 'YES') {
                 return false;
             }
         }
         $cc_expires_month = $_SESSION['ccdata']['order_payment_expire_month'];
         $cc_expires_year = $_SESSION['ccdata']['order_payment_expire_year'];
         //$cc_owner = ($_SESSION['ccdata']['order_payment_name']);
         //$cc_first = urlencode(substr($cc_owner, 0,(strrpos($cc_owner, " "))));
         //$cc_last = urlencode(substr($cc_owner,(strrpos($cc_owner, ' ') + 1),strlen($cc_owner)));
         $cc_expDate = urlencode($cc_expires_month . $cc_expires_year);
         $subject = urlencode('');
         $payer = urlencode($dbbt->f("user_email"));
         $first_name = urlencode(substr($dbbt->f("first_name"), 0, 50));
         $last_name = urlencode(substr($dbbt->f("last_name"), 0, 50));
         $currency_type = $GLOBALS['product_currency'];
         $ps_checkout = new ps_checkout();
         $order_totals = $ps_checkout->calc_order_totals($d);
         $tax_total = round($d['order_tax'], 2);
         $ship_total = isset($d['shipping_total']) ? round($d['shipping_total'], 2) : 0;
         $useshipping = PAYPAL_API_USE_SHIPPING;
         $db_new = new ps_DB();
         $query_str = "SELECT * FROM #__{vm}_country WHERE country_3_code='" . substr($dbbt->f("country"), 0, 60) . "'";
         $db_new->setQuery($query_str);
         $db_new->query();
         $db_new->next_record();
         $address_street1 = urlencode(substr($dbbt->f("address_1"), 0, 60));
         $address_city = urlencode(substr($dbbt->f("city"), 0, 40));
         $address_state = urlencode(substr($dbbt->f("state"), 0, 40));
         $address_country = urlencode($db_new->f("country_2_code"));
         $address_zip = urlencode(substr($dbbt->f("zip"), 0, 20));
         $query_str = "SELECT * FROM #__{vm}_country WHERE country_3_code='" . substr($dbst->f("country"), 0, 60) . "'";
         $db_new->setQuery($query_str);
         $db_new->query();
         $db_new->next_record();
         $ship_name = urlencode(trim(substr($dbst->f("first_name"), 0, 50) . ' ' . substr($dbst->f("last_name"), 0, 50)));
         $ship_street1 = urlencode(substr($dbst->f("address_1"), 0, 60));
         $ship_street2 = urlencode(substr($dbst->f("address_2"), 0, 60));
         $ship_city = urlencode(substr($dbst->f("city"), 0, 40));
         $ship_state = urlencode(substr($dbst->f("state"), 0, 40));
         $ship_country = urlencode($db_new->f("country_2_code"));
         $ship_zip = urlencode(substr($dbst->f("zip"), 0, 20));
         //Begin putting together our NVP Request
         $nvpreq = "&PAYMENTACTION={$payment_action}" . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'] . "&CREDITCARDTYPE={$cc_type}" . "&ACCT={$cc_number}" . "&EXPDATE={$cc_expDate}" . "&EMAIL={$payer}" . "&FIRSTNAME={$first_name}" . "&LASTNAME={$last_name}";
         if ($requireCVV == 'YES') {
             if (isset($cc_cvv2)) {
                 $nvpreq .= "&CVV2={$cc_cvv2}";
             } else {
                 return false;
             }
         }
         $nvpreq .= "&STREET={$address_street1}" . "&CITY={$address_city}" . "&STATE={$address_state}" . "&COUNTRYCODE={$address_country}" . "&ZIP={$address_zip}" . "&SHIPPINGAMT={$ship_total}";
         $nvpreq .= "&CURRENCYCODE={$currency_type}&TAXAMT={$tax_total}&DESC={$subject}&INVNUM={$ordernum}&BUTTONSOURCE=Virtuemart_Cart_DP";
         $nvpreq .= ps_paypal_api::getCartnvpstr($order_totals);
         //Put together Shipping NVP request
         $nvpreq .= "&AMT={$order_total}";
         if ($useshipping == '1') {
             $nvpreq .= "&SHIPTONAME={$ship_name}" . "&SHIPTOSTREET={$ship_street1}" . "&SHIPTOSTREET2={$ship_street2}" . "&SHIPTOCITY={$ship_city}" . "&SHIPTOSTATE={$ship_state}" . "&SHIPTOZIP={$ship_zip}" . "&SHIPTOCOUNTRYCODE={$ship_country}";
         }
         //return response to ps_paypal_wpp.php
         return $nvpreq;
     } else {
         return false;
     }
 }
    /**
     * This is the main function which stores the order information in the database
     * 
     * @author Ashish Solanki!
     * @return boolean
     */
    function updateRecords($order_number, $order_total, &$d)
    {
        require_once CLASSPATH . 'ps_checkout.php';
        $ps_chkout = new ps_checkout();
        global $order_tax_details, $afid, $VM_LANG, $auth, $my, $mosConfig_offset, $vmLogger, $vmInputFilter, $discount_factor;
        $ps_vendor_id = $_SESSION["ps_vendor_id"];
        $cart = $_SESSION['cart'];
        require_once CLASSPATH . 'ps_payment_method.php';
        $ps_payment_method = new ps_payment_method();
        require_once CLASSPATH . 'ps_product.php';
        $ps_product = new ps_product();
        require_once CLASSPATH . 'ps_cart.php';
        $ps_cart = new ps_cart();
        $db = new ps_DB();
        $totals = $ps_chkout->calc_order_totals($d);
        extract($totals);
        $timestamp = time();
        //Custom
        $vmLogger->debug('-- Checkout Debug--
							Subtotal: ' . $order_subtotal . '
							Taxable: ' . $order_taxable . '
							Payment Discount: ' . $payment_discount . '
							Coupon Discount: ' . $coupon_discount . '
							Shipping: ' . $order_shipping . '
							Shipping Tax : ' . $order_shipping_tax . '
							Tax : ' . $order_tax . '
							------------------------
							Order Total: ' . $order_total . '
							----------------------------');
        // Check to see if Payment Class File exists
        $payment_class = $ps_payment_method->get_field($d["payment_method_id"], "payment_class");
        $d['new_order_status'] = 'P';
        // This is meant to be updated by a payment modules' process_payment method
        if (!class_exists($payment_class)) {
            include CLASSPATH . "payment/{$payment_class}.php";
        }
        $_PAYMENT = new $payment_class();
        // Remove the Coupon, because it is a Gift Coupon and now is used!!
        if (@$_SESSION['coupon_type'] == "gift") {
            $d['coupon_id'] = $_SESSION['coupon_id'];
            include_once CLASSPATH . 'ps_coupon.php';
            ps_coupon::remove_coupon_code($d);
        }
        // Get the IP Address
        if (!empty($_SERVER['REMOTE_ADDR'])) {
            $ip = $_SERVER['REMOTE_ADDR'];
        } else {
            $ip = 'unknown';
        }
        // Collect all fields and values to store them!
        $fields = array('user_id' => $auth["user_id"], 'vendor_id' => $ps_vendor_id, 'order_number' => $order_number, 'user_info_id' => $d["ship_to_info_id"], 'ship_method_id' => @urldecode($d["shipping_rate_id"]), 'order_total' => $order_total, 'order_subtotal' => $order_subtotal, 'order_tax' => $order_tax, 'order_tax_details' => serialize($order_tax_details), 'order_shipping' => $order_shipping, 'order_shipping_tax' => $order_shipping_tax, 'order_discount' => $payment_discount, 'coupon_discount' => $coupon_discount, 'coupon_code' => @$_SESSION['coupon_code'], 'order_currency' => $GLOBALS['product_currency'], 'order_status' => 'P', 'cdate' => $timestamp, 'mdate' => $timestamp, 'customer_note' => htmlspecialchars(vmRequest::getString('customer_note', '', 'POST', 'none'), ENT_QUOTES), 'ip_address' => $ip);
        // Insert the main order information
        $db->buildQuery('INSERT', '#__{vm}_orders', $fields);
        $result = $db->query();
        $d["order_id"] = $order_id = $db->last_insert_id();
        if ($result === false || empty($order_id)) {
            $vmLogger->crit('Adding the Order into the Database failed! User ID: ' . $auth["user_id"]);
            return false;
        }
        // Insert the initial Order History.
        $mysqlDatetime = date("Y-m-d G:i:s", $timestamp);
        $fields = array('order_id' => $order_id, 'order_status_code' => 'P', 'date_added' => $mysqlDatetime, 'customer_notified' => 1, 'comments' => '');
        $db->buildQuery('INSERT', '#__{vm}_order_history', $fields);
        $db->query();
        /**
         * Insert the Order payment info 
         */
        $payment_number = str_replace(array(' ', '|', '-'), '', @$_SESSION['ccdata']['order_payment_number']);
        $d["order_payment_code"] = @$_SESSION['ccdata']['credit_card_code'];
        // Payment number is encrypted using mySQL encryption functions.
        $fields = array('order_id' => $order_id, 'payment_method_id' => $d["payment_method_id"], 'order_payment_log' => @$d["order_payment_log"], 'order_payment_trans_id' => $vmInputFilter->safeSQL(@$d["order_payment_trans_id"]));
        if (!empty($payment_number) && VM_STORE_CREDITCARD_DATA == '1') {
            // Store Credit Card Information only if the Store Owner has decided to do so
            $fields['order_payment_code'] = $d["order_payment_code"];
            $fields['order_payment_expire'] = @$_SESSION["ccdata"]["order_payment_expire"];
            $fields['order_payment_name'] = @$_SESSION["ccdata"]["order_payment_name"];
            $fields['order_payment_number'] = VM_ENCRYPT_FUNCTION . "( '{$payment_number}','" . ENCODE_KEY . "')";
            $specialfield = array('order_payment_number');
        } else {
            $specialfield = array();
        }
        $db->buildQuery('INSERT', '#__{vm}_order_payment', $fields, '', $specialfield);
        $db->query();
        /**
         * Insert the User Billto & Shipto Info
         */
        // First: get all the fields from the user field list to copy them from user_info into the order_user_info
        $fields = array();
        require_once CLASSPATH . 'ps_userfield.php';
        $userfields = ps_userfield::getUserFields('', false, '', true, true);
        foreach ($userfields as $field) {
            if ($field->name == 'email') {
                $fields[] = 'user_email';
            } else {
                $fields[] = $field->name;
            }
        }
        $fieldstr = implode(',', $fields);
        // Save current Bill To Address
        $q = "INSERT INTO `#__{vm}_order_user_info` \n\t\t\t(`order_info_id`,`order_id`,`user_id`,address_type, " . $fieldstr . ") ";
        $q .= "SELECT NULL, '{$order_id}', '" . $auth['user_id'] . "', address_type, " . $fieldstr . " FROM #__{vm}_user_info WHERE user_id='" . $auth['user_id'] . "' AND address_type='BT'";
        $db->query($q);
        // Save current Ship to Address if applicable
        $q = "INSERT INTO `#__{vm}_order_user_info` \n\t\t\t(`order_info_id`,`order_id`,`user_id`,address_type, " . $fieldstr . ") ";
        $q .= "SELECT NULL, '{$order_id}', '" . $auth['user_id'] . "', address_type, " . $fieldstr . " FROM #__{vm}_user_info WHERE user_id='" . $auth['user_id'] . "' AND user_info_id='" . $d['ship_to_info_id'] . "' AND address_type='ST'";
        $db->query($q);
        /**
         * Insert all Products from the Cart into order line items; 
         * one row per product in the cart 
         */
        $dboi = new ps_DB();
        for ($i = 0; $i < $cart["idx"]; $i++) {
            $r = "SELECT product_id,product_in_stock,product_sales,product_parent_id,product_sku,product_name ";
            $r .= "FROM #__{vm}_product WHERE product_id='" . $cart[$i]["product_id"] . "'";
            $dboi->query($r);
            $dboi->next_record();
            $product_price_arr = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
            $product_price = $GLOBALS['CURRENCY']->convert($product_price_arr["product_price"], $product_price_arr["product_currency"]);
            if (empty($_SESSION['product_sess'][$cart[$i]["product_id"]]['tax_rate'])) {
                $my_taxrate = $ps_product->get_product_taxrate($cart[$i]["product_id"]);
            } else {
                $my_taxrate = $_SESSION['product_sess'][$cart[$i]["product_id"]]['tax_rate'];
            }
            // Attribute handling
            $product_parent_id = $dboi->f('product_parent_id');
            $description = '';
            if ($product_parent_id > 0) {
                $db_atts = $ps_product->attribute_sql($dboi->f('product_id'), $product_parent_id);
                while ($db_atts->next_record()) {
                    $description .= $db_atts->f('attribute_name') . ': ' . $db_atts->f('attribute_value') . '; ';
                }
            }
            $description .= $ps_product->getDescriptionWithTax($_SESSION['cart'][$i]["description"], $dboi->f('product_id'));
            $product_final_price = round($product_price * ($my_taxrate + 1), 2);
            $vendor_id = $ps_vendor_id;
            $fields = array('order_id' => $order_id, 'user_info_id' => $d["ship_to_info_id"], 'vendor_id' => $vendor_id, 'product_id' => $cart[$i]["product_id"], 'order_item_sku' => $dboi->f("product_sku"), 'order_item_name' => $dboi->f("product_name"), 'product_quantity' => $cart[$i]["quantity"], 'product_item_price' => $product_price, 'product_final_price' => $product_final_price, 'order_item_currency' => $GLOBALS['product_currency'], 'order_status' => 'P', 'product_attribute' => $description, 'cdate' => $timestamp, 'mdate' => $timestamp);
            $db->buildQuery('INSERT', '#__{vm}_order_item', $fields);
            $db->query();
            // Update Stock Level and Product Sales, decrease - no matter if in stock or not!
            $q = "UPDATE #__{vm}_product ";
            $q .= "SET product_in_stock = product_in_stock - " . (int) $cart[$i]["quantity"];
            $q .= " WHERE product_id = '" . $cart[$i]["product_id"] . "'";
            $db->query($q);
            $q = "UPDATE #__{vm}_product ";
            $q .= "SET product_sales= product_sales + " . (int) $cart[$i]["quantity"];
            $q .= " WHERE product_id='" . $cart[$i]["product_id"] . "'";
            $db->query($q);
            // Update stock of parent product, if all child products are sold, thanks Ragnar Brynjulfsson
            if ($dboi->f("product_parent_id") != 0) {
                $q = "SELECT COUNT(product_id) ";
                $q .= "FROM #__{vm}_product ";
                $q .= "WHERE product_parent_id = " . $dboi->f("product_parent_id");
                $q .= " AND product_in_stock > 0";
                $db->query($q);
                $db->next_record();
                if (!$db->f("COUNT(product_id)")) {
                    $q = "UPDATE #__{vm}_product ";
                    $q .= "SET product_in_stock = 0 ";
                    $q .= "WHERE product_id = " . $dboi->f("product_parent_id") . " LIMIT 1";
                    $db->query($q);
                }
            }
        }
        ######## BEGIN DOWNLOAD MOD ###############
        if (ENABLE_DOWNLOADS == "1") {
            require_once CLASSPATH . 'ps_order.php';
            for ($i = 0; $i < $cart["idx"]; $i++) {
                // only handle downloadable products here
                if (ps_product::is_downloadable($cart[$i]["product_id"])) {
                    $params = array('product_id' => $cart[$i]["product_id"], 'order_id' => $order_id, 'user_id' => $auth["user_id"]);
                    ps_order::insert_downloads_for_product($params);
                    if (@VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') {
                        // Update the product stock level back to where it was.
                        $q = "UPDATE #__{vm}_product ";
                        $q .= "SET product_in_stock = product_in_stock + " . (int) $cart[$i]["quantity"];
                        $q .= " WHERE product_id = '" . (int) $cart[$i]["product_id"] . "'";
                        $db->query($q);
                    }
                }
            }
        }
        ################## END DOWNLOAD MOD ###########
        // Export the order_id so the checkout complete page can get it
        $d["order_id"] = $order_id;
        /*
         * Let the shipping module know which shipping method
         * was selected.  This way it can save any information
         * it might need later to print a shipping label.
         */
        if (is_callable(array($this->_SHIPPING, 'save_rate_info'))) {
            $this->_SHIPPING->save_rate_info($d);
        }
        // Now as everything else has been done, we can update the Order Status
        $update_order = false;
        if ($order_total == 0.0) {
            // code moved out of $_PAYMENT check as no payment will be needed when $order_total=0.0
            // If the Order Total is zero, we can confirm the order to automatically enable the download
            $d['order_status'] = ENABLE_DOWNLOAD_STATUS;
            $update_order = true;
        } elseif (isset($_PAYMENT)) {
            if ($d['new_order_status'] != 'P') {
                $d['order_status'] = $d['new_order_status'];
                $update_order = true;
            }
        }
        if ($update_order) {
            require_once CLASSPATH . "ps_order.php";
            $ps_order = new ps_order();
            $ps_order->order_status_update($d);
        }
        // Send the e-mail confirmation messages
        $ps_chkout->email_receipt($order_id);
        // Reset the cart (=empty it)
        $ps_cart->reset();
        $_SESSION['savedcart']['idx'] = 0;
        $ps_cart->saveCart();
        // Unset the payment_method variables
        $d["payment_method_id"] = "";
        $d["order_payment_number"] = "";
        $d["order_payment_expire"] = "";
        $d["order_payment_name"] = "";
        $d["credit_card_code"] = "";
        // Clear the sensitive Session data
        $_SESSION['ccdata']['order_payment_name'] = "";
        $_SESSION['ccdata']['order_payment_number'] = "";
        $_SESSION['ccdata']['order_payment_expire_month'] = "";
        $_SESSION['ccdata']['order_payment_expire_year'] = "";
        $_SESSION['ccdata']['credit_card_code'] = "";
        $_SESSION['coupon_discount'] = "";
        $_SESSION['coupon_id'] = "";
        $_SESSION['coupon_redeemed'] = false;
        $_POST["payment_method_id"] = "";
        $_POST["order_payment_number"] = "";
        $_POST["order_payment_expire"] = "";
        $_POST["order_payment_name"] = "";
        $_SESSION['order_id'] = $order_id;
    }
                //Create our array like the form
                //Just in case so we don't mess anything up when
                //doing ps_checkout->process()
                $checkoutData = array('option' => 'com_virtuemart', 'Itemid' => $Itemid, 'user_id' => (int) $auth['user_id'], 'page' => 'checkout.thankyou', 'func' => 'checkoutProcess', 'zone_qty' => $zone_qty, 'ship_to_info_id' => $ship_to_info_id, 'shipping_rate_id' => urlencode($shipping_rate_id), 'ship_method_id' => $shipping_rate_id, 'payment_method_id' => $payment_method_id, 'checkout_last_step' => '4', 'checkout_this_step' => array('CHECK_OUT_GET_FINAL_CONFIRMATION'));
                //Make sure to set the request variables before creating a new ps_checkout();
                //Just in case
                $_REQUEST['shipping_rate_id'] = urlencode($shipping_rate_id);
                $_REQUEST['ship_method_id'] = $shipping_rate_id;
                $_REQUEST['user_id'] = (int) $auth['user_id'];
                $_REQUEST['zone_qty'] = $zone_qty;
                $_REQUEST['ship_to_info_id'] = $ship_to_info_id;
                $_REQUEST['payment_method_id'] = $payment_method_id;
                //Set our $_SESSION variable for DoExpressCheckout
                //So we know which way we came from
                $_SESSION['ppex_cart_ecm'] = '1';
                $checkout = new ps_checkout();
                //Try to process the order
                //On Success redirect to checkout.thankyou
                if ($checkout->process($checkoutData)) {
                    vmRedirect($sess->url('index.php?page=checkout.thankyou&order_id=' . $checkoutData['order_id'], false, false));
                }
            } else {
                $vmLogger->err(@$nvp_common_015);
            }
        }
    }
}
$theme = new $GLOBALS['VM_THEMECLASS']();
$theme->set_vars(array('zone_qty' => $zone_qty, 'ship_to_info_id' => $ship_to_info_id, 'shipping_rate_id' => $shipping_rate_id, 'current_stage' => $current_stage, 'payment_method_id' => $payment_method_id, 'weight_total' => $weight_total, 'Itemid' => $Itemid));
if ($cart["idx"] > 0) {
    echo '<h3>' . $VM_LANG->_('PHPSHOP_CHECKOUT_TITLE') . '</h3>';
Example #8
0
 function _tax_based_on_vendor_address()
 {
     global $auth;
     global $vmLogger;
     switch (TAX_MODE) {
         case '0':
             return false;
         case '1':
             return true;
         case '17749':
             if (!array_key_exists('country', $auth)) {
                 $vmLogger->debug('shopper\'s country is not known; defaulting to vendor-based tax');
                 return true;
             }
             $vmLogger->debug('shopper is in ' . $auth['country']);
             return ps_checkout::country_in_eu_common_vat_zone($auth['country']);
         default:
             $vmLogger->warning('unknown TAX_MODE "' . TAX_MODE . '"');
             return true;
     }
 }
Example #9
0
 /**
  * Returns all payment_methods with given selector in a Radiolist
  *
  * @param string $selector A String like "B" identifying a type of payment methods
  * @param int $payment_method_id An ID to preselect
  * @param boolean $horiz Separate Items with Spaces if true, else with <br />
  * @return string
  */
 function list_payment_radio($selector, $payment_method_id, $horiz)
 {
     global $CURRENCY_DISPLAY, $ps_checkout;
     $ps_vendor_id = $_SESSION["ps_vendor_id"];
     $auth = $_SESSION["auth"];
     $db = new ps_DB();
     if (!isset($ps_checkout)) {
         $ps_checkout = new ps_checkout();
     }
     require_once CLASSPATH . 'ps_shopper_group.php';
     $ps_shopper_group = new ps_shopper_group();
     $q = "SELECT shopper_group_id from #__{vm}_shopper_group WHERE ";
     $q .= "`default`='1' ";
     $db->query($q);
     if (!$db->num_rows()) {
         $q = "SELECT shopper_group_id from #__{vm}_shopper_group";
         $db->query($q);
     }
     $db->next_record();
     $default_shopper_group_id = $db->f("shopper_group_id");
     $q = "SELECT payment_method_id,payment_method_discount, payment_method_discount_is_percent, payment_method_name from #__{vm}_payment_method WHERE ";
     $q .= "(enable_processor='{$selector}') AND ";
     $q .= "payment_enabled='Y' AND ";
     $q .= "vendor_id='{$ps_vendor_id}' AND ";
     if ($auth["shopper_group_id"] == $default_shopper_group_id) {
         $q .= "shopper_group_id='{$default_shopper_group_id}' ";
     } else {
         $q .= "(shopper_group_id='{$default_shopper_group_id}' ";
         $q .= "OR shopper_group_id='" . $auth["shopper_group_id"] . "') ";
     }
     $q .= "ORDER BY list_order";
     $db->query($q);
     $has_result = false;
     // Start radio list
     while ($db->next_record()) {
         $has_result = true;
         echo "<input type=\"radio\" name=\"payment_method_id\" id=\"" . $db->f("payment_method_name") . "\" value=\"" . $db->f("payment_method_id") . "\" ";
         if ($selector == "' OR enable_processor='Y") {
             echo "onchange=\"javascript: changeCreditCardList();\" ";
         }
         if (($db->f("payment_method_id") == $payment_method_id || $db->num_rows() < 2) && !@$GLOBALS['payment_selected']) {
             echo "checked=\"checked\" />\n";
             $GLOBALS['payment_selected'] = true;
         } else {
             echo "/>\n";
         }
         $discount = $ps_checkout->get_payment_discount($db->f("payment_method_id"));
         echo "<label for=\"" . $db->f("payment_method_name") . "\">" . $db->f("payment_method_name");
         if ($discount > 0.0) {
             echo " (- " . $CURRENCY_DISPLAY->getFullValue(abs($discount)) . ") \n";
         } elseif ($discount < 0.0) {
             echo " (+ " . $CURRENCY_DISPLAY->getFullValue(abs($discount)) . ") \n";
         }
         echo "</label>";
         if ($horiz) {
             echo " ";
         } else {
             echo "<br />";
         }
     }
     return $has_result;
 }
        echo "<input type=\"hidden\" name=\"payment_method_id\" value=\"{$payment_method_id}\" />\n";
        echo "<input type=\"hidden\" name=\"task\" value=\"changekey\" />\n";
        echo "<input type=\"hidden\" name=\"pshop_mode\" value=\"admin\" />\n";
        echo "<input type=\"hidden\" name=\"page\" value=\"store.payment_method_keychange\" />\n";
        echo "</form>\n";
    } elseif ($auth_result && !empty($passkey) && $task == "changekey") {
        $q = "UPDATE #__{vm}_payment_method ";
        $q .= "SET payment_passkey = " . VM_ENCRYPT_FUNCTION . "('{$passkey}','" . ENCODE_KEY . "')\n";
        $q .= "WHERE payment_method_id='{$payment_method_id}';";
        $db->query($q);
        vmRedirect($sess->url($_SERVER['PHP_SELF'] . "?page=store.payment_method_form&payment_method_id={$payment_method_id}", false, false), $VM_LANG->_('PHPSHOP_CHANGE_PASSKEY_SUCCESS'));
    } else {
        require_once CLASSPATH . "ps_checkout.php";
        echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">\n";
        echo "<table class=\"adminForm\">\n";
        echo "<tr><td>" . $VM_LANG->_('PHPSHOP_CURRENT_TRANSACTION_KEY') . ":</td><td>" . ($db->f('passkey') ? ps_checkout::asterisk_pad($db->f('passkey'), 4) : '<i>(empty!)</i>') . "</td></tr>\n";
        echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
        echo "<tr><td>" . $VM_LANG->_('PHPSHOP_TYPE_PASSWORD') . ":</td>\n";
        echo "<td><input type=\"password\" name=\"passwd\" value=\"\" /></td></tr>\n";
        echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
        echo "<tr><td>&nbsp;</td><td><input name=\"submit\" type=\"submit\" value=\"" . $VM_LANG->_('PHPSHOP_SUBMIT') . "\" /></td></tr>\n";
        echo "</table>\n";
        echo "<input type=\"hidden\" name=\"option\" value=\"com_virtuemart\" />\n";
        echo "<input type=\"hidden\" name=\"Itemid\" value=\"{$Itemid}\" />\n";
        echo "<input type=\"hidden\" name=\"pshop_mode\" value=\"admin\" />\n";
        echo "<input type=\"hidden\" name=\"payment_method_id\" value=\"{$payment_method_id}\" />\n";
        echo "<input type=\"hidden\" name=\"page\" value=\"store.payment_method_keychange\" />\n";
        echo "</form>\n";
    }
    echo '</td></tr></table>';
} else {
<?php

if (!defined('_VALID_MOS') && !defined('_JEXEC')) {
    die('Direct Access to ' . basename(__FILE__) . ' is not allowed.');
}
/**
*
* @version $Id: get_shipping_method.tpl.php 1140 2008-01-09 20:44:35Z soeren_nb $
* @package VirtueMart
* @subpackage templates
* @copyright Copyright (C) 2007 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
ps_checkout::show_checkout_bar();
echo $basket_html;
echo '<br />';
$varname = 'PHPSHOP_CHECKOUT_MSG_' . CHECK_OUT_GET_SHIPPING_METHOD;
echo '<h4>' . $VM_LANG->_($varname) . '</h4>';
ps_checkout::list_shipping_methods($ship_to_info_id, $shipping_rate_id);
* -CHECK_OUT_GET_SHIPPING_METHOD
* let the user choose a shipto metho for the ship to address

* -CHECK_OUT_GET_PAYMENT_METHOD
* let the user choose a payment method

* -CHECK_OUT_GET_FINAL_CONFIRMATION
* shows a total summary including all payments, taxes, fees etc. and let the user confirm
*/
if ($auth['user_id'] > 0) {
    $show_basket = true;
} else {
    $show_basket = false;
}
$current_stage = ps_checkout::get_current_stage();
$checkout_steps = ps_checkout::get_checkout_steps();
if (in_array('CHECK_OUT_GET_FINAL_CONFIRMATION', $checkout_steps[$current_stage])) {
    $next_page = 'checkout.thankyou';
    if (sizeof($checkout_steps[$current_stage]) > 1) {
        include_once PAGEPATH . 'basket.php';
    } else {
        include_once PAGEPATH . 'ro_basket.php';
    }
} else {
    $next_page = 'checkout.index';
    include_once PAGEPATH . 'basket.php';
}
// Get the zone quantity after it has been calculated in the basket
$zone_qty = vmGet($_REQUEST, 'zone_qty');
$theme = new $GLOBALS['VM_THEMECLASS']();
$theme->set_vars(array('zone_qty' => $zone_qty, 'ship_to_info_id' => $ship_to_info_id, 'shipping_rate_id' => $shipping_rate_id, 'payment_method_id' => $payment_method_id, 'weight_total' => $weight_total, 'Itemid' => $Itemid));
Example #13
0
 function process_coupon_code($d)
 {
     global $VM_LANG, $vmLogger;
     /* init the database */
     $coupon_db = new ps_DB();
     /* we need some functions from the checkout module */
     require_once CLASSPATH . "ps_checkout.php";
     $checkout = new ps_checkout();
     if (empty($d['total'])) {
         $totals = $checkout->calc_order_totals($d);
         $d['total'] = $totals['order_subtotal'] + $totals['order_tax'] + $totals['order_shipping'] + $totals['order_shipping_tax'] - $totals['payment_discount'];
     }
     $d['coupon_code'] = trim(vmGet($_REQUEST, 'coupon_code'));
     $coupon_id = vmGet($_SESSION, 'coupon_id', null);
     $q = 'SELECT coupon_id, coupon_code, percent_or_total, coupon_value, coupon_type FROM #__{vm}_coupons WHERE ';
     if ($coupon_id) {
         /* the query to select the coupon coupon_code */
         $q .= 'coupon_id = ' . intval($coupon_id);
     } else {
         /* the query to select the coupon coupon_code */
         $q .= 'coupon_code = \'' . $coupon_db->getEscaped($d['coupon_code']) . '\'';
     }
     /* make the query */
     $coupon_db->query($q);
     /* see if we have any fields returned */
     if ($coupon_db->num_rows() > 0) {
         /* we have a record */
         /* see if we are calculating percent or dollar discount */
         if ($coupon_db->f("percent_or_total") == "percent") {
             /* percent */
             //$subtotal = $checkout->calc_order_subtotal( $d );
             /* take the subtotal for calculation of the discount */
             //$_SESSION['coupon_discount'] = round( ($subtotal * $coupon_db->f("coupon_value") / 100), 2);
             $coupon_value = round($d["total"] * $coupon_db->f("coupon_value") / 100, 2);
             if ($d["total"] < $coupon_value) {
                 $coupon_value = (double) $d['total'] + (double) $d['order_tax'];
                 $vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
             }
             $_SESSION['coupon_discount'] = $coupon_value;
         } else {
             $coupon_value = $coupon_db->f("coupon_value");
             /* Total Amount */
             if ($d["total"] < $coupon_value) {
                 $coupon_value = (double) $d['total'] + (double) $d['order_tax'];
                 $vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
             }
             $_SESSION['coupon_discount'] = $GLOBALS['CURRENCY']->convert($coupon_value);
         }
         /* mark this order as having used a coupon so people cant go and use coupons over and over */
         $_SESSION['coupon_redeemed'] = true;
         $_SESSION['coupon_id'] = $coupon_db->f("coupon_id");
         $_SESSION['coupon_code'] = $coupon_db->f("coupon_code");
         $_SESSION['coupon_type'] = $coupon_db->f("coupon_type");
     } else {
         /* no record, so coupon_code entered was not valid */
         $GLOBALS['coupon_error'] = $VM_LANG->_('PHPSHOP_COUPON_CODE_INVALID');
         return false;
     }
 }
Example #14
0
 /**
  * Retrieves the tax rate to apply to a shipping rate
  *
  * @param int $shipping_rate_id
  * @return float
  */
 function get_tax_rate($shipping_rate_id = 0)
 {
     global $vendor_country_3_code;
     $db = new ps_DB();
     // added by sobers_2002 to fix the issue with shipping tax being calculated for non-state orders
     $ship_to_info_id = vmGet($_REQUEST, 'ship_to_info_id');
     $q = "SELECT state, country FROM #__{vm}_user_info ";
     $q .= "WHERE user_info_id='" . $ship_to_info_id . "'";
     $db->query($q);
     $db->next_record();
     $state = $db->f("state");
     // EU VAT check
     $auth = $_SESSION['auth'];
     $userid = $auth["user_id"];
     if ($userid > 0 && TAX_MODE == '17749' && ps_checkout::country_in_eu_common_vat_zone($vendor_country_3_code)) {
         $ship_country = '';
         $user_info_id = '';
         if (vmGet($_REQUEST, 'ship_to_info_id') || $ship_to_info_id) {
             if (!$ship_to_info_id) {
                 $ship_to_info_id = vmGet($_REQUEST, 'ship_to_info_id');
             }
             $q = "SELECT country FROM #__{vm}_user_info WHERE user_info_id='" . $ship_to_info_id . "'";
             $db->query($q);
             $db->next_record();
             $ship_country = $db->f("country");
         }
         if ($ship_to_info_id == '') {
             $ship_country = $auth["country"];
             $q = "SELECT user_info_id FROM #__{vm}_user_info WHERE user_id = '" . (int) $userid . "' AND address_type='BT'";
             $db->query($q);
             $user_info_id = $db->f("user_info_id");
         }
         // Check if user country is inside EU.
         $eu_vat = '';
         if (ps_checkout::country_in_eu_common_vat_zone($ship_country)) {
             $eu_vat = 'yes';
             $q = "SELECT name FROM #__{vm}_userfield WHERE type='euvatid' AND published=1";
             $db->query($q);
             $vatid_fieldname = $db->f('name');
         }
         // Handle TAX if EU VAT ID
         if ($eu_vat == 'yes' && $vendor_country_3_code != $ship_country) {
             $q = "SELECT country_2_code FROM #__{vm}_country WHERE country_3_code='" . $ship_country . "'";
             $db->query($q);
             $db->next_record();
             $ship_country_2_code = $db->f("country_2_code");
             if ($vatid_fieldname) {
                 $q = "SELECT `{$vatid_fieldname}` FROM #__{vm}_user_info WHERE user_info_id='" . $ship_to_info_id . "' OR user_info_id='" . $user_info_id . "'";
                 $db->query($q);
                 while ($db->next_record()) {
                     $vat_id = $db->f($vatid_fieldname);
                     if ($ship_country_2_code == substr($vat_id, 0, 2)) {
                         return 0.0;
                     }
                 }
             }
         }
     }
     if ($shipping_rate_id == 0) {
         $shipping_rate_id = vmGet($_REQUEST, "shipping_rate_id");
         $ship_arr = explode("|", urldecode(urldecode($shipping_rate_id)));
         $shipping_rate_id = (int) $ship_arr[4];
     }
     $q = "SELECT tax_rate FROM #__{vm}_shipping_rate,#__{vm}_tax_rate WHERE shipping_rate_id='{$shipping_rate_id}' AND shipping_rate_vat_id=tax_rate_id";
     // check if state tax is applicable to the user
     if ($state) {
         $q .= " AND (tax_state='{$state}' OR tax_state=' {$state} ' OR rtrim(ltrim(tax_state))='-' OR tax_state is null)";
     }
     $db->query($q);
     $db->next_record();
     if ($db->f('tax_rate')) {
         return $db->f('tax_rate');
     } else {
         return 0.0;
     }
 }
Example #15
0
 /**
  * Adjusts the price from get_price for the selected attributes
  * @author Nathan Hyde <*****@*****.**>
  * @author curlyroger from his post at <http://www.phpshop.org/phpbb/viewtopic.php?t=3052>
  *
  * @param int $product_id
  * @param string $description
  * @return array The adjusted price information
  */
 function get_adjusted_attribute_price($product_id, $description = '')
 {
     global $mosConfig_secret;
     $auth = $_SESSION['auth'];
     $price = $this->get_price($product_id);
     $base_price = $price["product_price"];
     $setprice = 0;
     $set_price = false;
     $adjustment = 0;
     // We must care for custom attribute fields! Their value can be freely given
     // by the customer, so we mustn't include them into the price calculation
     // Thanks to AryGroup@ua.fm for the good advice
     if (empty($_REQUEST["custom_attribute_fields"])) {
         if (!empty($_SESSION["custom_attribute_fields"])) {
             $custom_attribute_fields = vmGet($_SESSION, "custom_attribute_fields", array());
             $custom_attribute_fields_check = vmGet($_SESSION, "custom_attribute_fields_check", array());
         } else {
             $custom_attribute_fields = $custom_attribute_fields_check = array();
         }
     } else {
         $custom_attribute_fields = $_SESSION["custom_attribute_fields"] = vmGet($_REQUEST, "custom_attribute_fields", array());
         $custom_attribute_fields_check = $_SESSION["custom_attribute_fields_check"] = vmGet($_REQUEST, "custom_attribute_fields_check", array());
     }
     // if we've been given a description to deal with, get the adjusted price
     if ($description != '') {
         // description is safe to use at this point cause it's set to ''
         require_once CLASSPATH . 'ps_product_attribute.php';
         $product_attributes = ps_product_attribute::getAdvancedAttributes($product_id, true);
         $attribute_keys = explode(";", $description);
         for ($i = 0; $i < sizeof($attribute_keys); $i++) {
             $temp_desc = $attribute_keys[$i];
             $temp_desc = trim($temp_desc);
             // Get the key name (e.g. "Color" )
             $this_key = substr($temp_desc, 0, strpos($temp_desc, ":"));
             $this_value = substr($temp_desc, strpos($temp_desc, ":") + 1);
             if (in_array($this_key, $custom_attribute_fields)) {
                 if (@$custom_attribute_fields_check[$this_key] == md5($mosConfig_secret . $this_key)) {
                     // the passed value is valid, don't use it for calculating prices
                     continue;
                 }
             }
             if (isset($product_attributes[$this_key]['values'][$this_value])) {
                 $modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
                 $operand = $product_attributes[$this_key]['values'][$this_value]['operand'];
                 // if we have a number, allow the adjustment
                 if (true == is_numeric($modifier)) {
                     // Now add or sub the modifier on
                     if ($operand == "+") {
                         $adjustment += $modifier;
                     } else {
                         if ($operand == "-") {
                             $adjustment -= $modifier;
                         } else {
                             if ($operand == '=') {
                                 // NOTE: the +=, so if we have 2 sets they get added
                                 // this could be moded to say, if we have a set_price, then
                                 // calc the diff from the base price and start from there if we encounter
                                 // another set price... just a thought.
                                 $setprice += $modifier;
                                 $set_price = true;
                             }
                         }
                     }
                 }
             } else {
                 continue;
             }
         }
     }
     // no set price was set from the attribs
     if ($set_price == false) {
         $price["product_price"] = $base_price + $adjustment * (1 - $auth["shopper_group_discount"] / 100);
     } else {
         // otherwise, set the price
         // add the base price to the price set in the attributes
         // then subtract the adjustment amount
         // we could also just add the set_price to the adjustment... not sure on that one.
         if (!empty($adjustment)) {
             $setprice += $adjustment;
         }
         $setprice *= 1 - $auth["shopper_group_discount"] / 100;
         $price["product_price"] = $setprice;
     }
     // don't let negative prices get by, set to 0
     if ($price["product_price"] < 0) {
         $price["product_price"] = 0;
     }
     // Get the DISCOUNT AMOUNT
     $discount_info = $this->get_discount($product_id);
     $my_taxrate = $this->get_product_taxrate($product_id);
     // If discounts are applied after tax, but prices are shown without tax,
     // AND tax is EU mode and shopper is not in the EU,
     // then ps_product::get_product_taxrate() returns 0, so $my_taxrate = 0.
     // But, the discount still needs to be reduced by the shopper's tax rate, so we obtain it here:
     if (PAYMENT_DISCOUNT_BEFORE != '1' && $auth["show_price_including_tax"] != 1 && !ps_checkout::tax_based_on_vendor_address()) {
         $db = new ps_DB();
         $ps_vendor_id = $_SESSION["ps_vendor_id"];
         require_once CLASSPATH . 'ps_checkout.php';
         if (!ps_checkout::tax_based_on_vendor_address()) {
             if ($auth["user_id"] > 0) {
                 $q = "SELECT state, country FROM #__{vm}_user_info WHERE user_id='" . $auth["user_id"] . "'";
                 $db->query($q);
                 $db->next_record();
                 $state = $db->f("state");
                 $country = $db->f("country");
                 $q = "SELECT tax_rate FROM #__{vm}_tax_rate WHERE tax_country='{$country}' ";
                 if (!empty($state)) {
                     $q .= "AND (tax_state='{$state}' OR tax_state=' {$state} ' OR tax_state='-')";
                 }
                 $db->query($q);
                 if ($db->next_record()) {
                     $my_taxrate = $db->f("tax_rate");
                 } else {
                     $my_taxrate = 0;
                 }
             } else {
                 $my_taxrate = 0;
             }
         } else {
             if (empty($_SESSION['taxrate'][$ps_vendor_id])) {
                 // let's get the store's tax rate
                 $q = "SELECT `tax_rate` FROM #__{vm}_vendor, #__{vm}_tax_rate ";
                 $q .= "WHERE tax_country=vendor_country AND #__{vm}_vendor.vendor_id=1 ";
                 // !! Important !! take the highest available tax rate for the store's country
                 $q .= "ORDER BY `tax_rate` DESC";
                 $db->query($q);
                 if ($db->next_record()) {
                     $my_taxrate = $db->f("tax_rate");
                 } else {
                     $my_taxrate = 0;
                 }
             }
         }
     }
     // Apply the discount
     if (!empty($discount_info["amount"])) {
         $undiscounted_price = $base_price;
         switch ($discount_info["is_percent"]) {
             case 0:
                 if (PAYMENT_DISCOUNT_BEFORE == '1') {
                     // If we subtract discounts BEFORE tax
                     // Subtract the whole discount
                     $price["product_price"] -= $discount_info["amount"];
                 } else {
                     // But, if we subtract discounts AFTER tax
                     // Subtract the untaxed portion of the discount
                     $price["product_price"] -= $discount_info["amount"] / ($my_taxrate + 1);
                 }
                 break;
             case 1:
                 $price["product_price"] -= $price["product_price"] * ($discount_info["amount"] / 100);
                 break;
         }
     }
     return $price;
 }
Example #16
0
* @subpackage html
* @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
require_once CLASSPATH . 'ps_checkout.php';
$ps_checkout = new ps_checkout();
require_once CLASSPATH . 'ps_shipping_method.php';
global $weight_total, $total, $tax_total, $order_tax_details, $discount_factor, $order_total;
/* make sure this is the checkout screen */
if ($cart["idx"] == 0) {
    $basket_html = $VM_LANG->_('PHPSHOP_EMPTY_CART');
    $checkout = False;
} else {
    $checkout = True;
    $total = 0;
    $grandSubtotal = 0;
    // Added for the zone shipping module
    $vars["zone_qty"] = 0;
    $weight_total = 0;
    $weight_subtotal = 0;
    $tax_total = 0;
Example #17
0
 function _tax_based_on_vendor_address($ship_to_info_id = '')
 {
     global $auth;
     global $vmLogger;
     switch (TAX_MODE) {
         case '0':
             return false;
         case '1':
             return true;
         case '17749':
             $ship_to_info_id = !empty($ship_to_info_id) ? $ship_to_info_id : vmGet($_REQUEST, 'ship_to_info_id');
             $db = new ps_DB();
             $q = "SELECT country FROM #__{vm}_user_info WHERE user_info_id='" . $ship_to_info_id . "'";
             $db->query($q);
             $db->next_record();
             $ship_country = $db->f("country");
             if (!array_key_exists('country', $auth) || empty($ship_country)) {
                 $vmLogger->debug('shopper\'s country is not known; defaulting to vendor-based tax');
                 return true;
             }
             if ($ship_to_info_id) {
                 $vmLogger->debug('shopper shipping in ' . $ship_country);
                 $auth_country = $ship_country;
             } else {
                 $vmLogger->debug('shopper is in ' . $auth['country']);
                 $auth_country = $auth['country'];
             }
             return ps_checkout::country_in_eu_common_vat_zone($auth_country);
         default:
             $vmLogger->warning('unknown TAX_MODE "' . TAX_MODE . '"');
             return true;
     }
 }
<?php

if (!defined('_VALID_MOS') && !defined('_JEXEC')) {
    die('Direct Access to ' . basename(__FILE__) . ' is not allowed.');
}
/**
*
* @version $Id: get_payment_method.tpl.php 1140 2008-01-09 20:44:35Z soeren_nb $
* @package VirtueMart
* @subpackage templates
* @copyright Copyright (C) 2007 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
ps_checkout::show_checkout_bar();
echo $basket_html;
echo '<br />';
$varname = 'PHPSHOP_CHECKOUT_MSG_' . CHECK_OUT_GET_PAYMENT_METHOD;
echo '<h4>' . $VM_LANG->_($varname) . '</h4>';
echo ps_checkout::list_payment_methods($payment_method_id);
	$state_name = $dbs->f("state_name");
	echo vmFormatAddress( array('name' => $db->f("first_name")." ".$db->f("last_name"),
        								'address_1' => $db->f("address_1"),
        								'address_2' => $db->f("address_2"),
        								'state' => $db->f("state"),
        								'state_name' => $state_name,
        								'zip' => $db->f("zip"),
        								'city' => $db->f("city"),
        								'country' => $db->f('country')
        							), true );
	
	echo "</td></tr>";
}

// Print out the Selected Shipping Method
if(!ps_checkout::noShippingMethodNecessary()) {

	echo '<tr><td valign="top"><strong>'.$VM_LANG->_('PHPSHOP_INFO_MSG_SHIPPING_METHOD') . ":</strong></td>";
	$rate_details = explode( "|", urldecode(urldecode(vmGet($_REQUEST,'shipping_rate_id'))) );
	echo '<td>';
	foreach( $rate_details as $k => $v ) {
		// thepisu: old sample data cointaned "&gt;" instead of ">"... 
		// so we don't have to make safe if "&gt;" is found
		if (strpos($v,"&gt;")===false) {
			$v = shopMakeHtmlSafe($v);
		}
		if( $k == 3 ) {
			echo $CURRENCY_DISPLAY->getFullValue( $v )."; ";
		} elseif( $k > 0 && $k < 4) {
			echo $v.'; ';
		}
Example #20
0
 function resendconfirm()
 {
     $order_id = JRequest::getInt('localid', 0);
     if (!empty($order_id)) {
         $x = @ps_checkout::email_receipt($order_id);
     }
     if ($x != false) {
         echo 'Email sent! <br />';
     } else {
         echo 'Email PROBLEM!<br />';
     }
     $mainframe = JFactory::getApplication();
     $mainframe->close();
 }