當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wpsc_cart_total函數代碼示例

本文整理匯總了PHP中wpsc_cart_total函數的典型用法代碼示例。如果您正苦於以下問題:PHP wpsc_cart_total函數的具體用法?PHP wpsc_cart_total怎麽用?PHP wpsc_cart_total使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wpsc_cart_total函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _wpsc_get_checkout_info

/**
 * Get replacement elements for country and region fields on the checkout form
 *
 *  Note: extracted from the wpsc_change_tax function in ajax.php as of version 3.8.13.3
 *
 * @since 3.8.14
 * @access private
 * @return array  checkout information
 */
function _wpsc_get_checkout_info()
{
    global $wpsc_cart;
    // Checkout info is what we will return to the AJAX client
    $checkout_info = array();
    // start with items that have no dependencies
    $checkout_info['delivery_country'] = wpsc_get_customer_meta('shippingcountry');
    $checkout_info['billing_country'] = wpsc_get_customer_meta('billingcountry');
    $checkout_info['country_name'] = wpsc_get_country($checkout_info['delivery_country']);
    $checkout_info['lock_tax'] = get_option('lock_tax');
    // TODO: this is set anywhere, probably deprecated
    $checkout_info['needs_shipping_recalc'] = wpsc_cart_need_to_recompute_shipping_quotes();
    $checkout_info['shipping_keys'] = array();
    foreach ($wpsc_cart->cart_items as $key => $cart_item) {
        $checkout_info['shipping_keys'][$key] = wpsc_currency_display($cart_item->shipping);
    }
    if (!$checkout_info['needs_shipping_recalc']) {
        $wpsc_cart->update_location();
        $wpsc_cart->get_shipping_method();
        $wpsc_cart->get_shipping_option();
        if ($wpsc_cart->selected_shipping_method != '') {
            $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
        }
        $tax = $wpsc_cart->calculate_total_tax();
        $total = wpsc_cart_total();
        $total_input = wpsc_cart_total(false);
        if ($wpsc_cart->coupons_amount >= $total_input && !empty($wpsc_cart->coupons_amount)) {
            $total = 0;
        }
        if ($wpsc_cart->total_price < 0) {
            $wpsc_cart->coupons_amount += $wpsc_cart->total_price;
            $wpsc_cart->total_price = null;
            $wpsc_cart->calculate_total_price();
        }
        $cart_widget = _wpsc_ajax_get_cart(false);
        if (isset($cart_widget['widget_output']) && !empty($cart_widget['widget_output'])) {
            $checkout_info['widget_output'] = $cart_widget['widget_output'];
        }
        $checkout_info['cart_shipping'] = wpsc_cart_shipping();
        $checkout_info['tax'] = $tax;
        $checkout_info['display_tax'] = wpsc_cart_tax();
        $checkout_info['total'] = $total;
        $checkout_info['total_input'] = $total_input;
    }
    return apply_filters('wpsc_ajax_checkout_info', $checkout_info);
}
開發者ID:dreamteam111,項目名稱:dreamteam,代碼行數:55,代碼來源:wpsc-checkout-ajax.php

示例2: wpsc_cart_total

   	</tr>
	  <?php 
    }
    ?>

		
	
	<tr class='total_price'>
		<td colspan='3'>
		<?php 
    echo TXT_WPSC_TOTALPRICE;
    ?>
		</td>
		<td colspan='2'>
			<span id='checkout_total' class="pricedisplay checkout-total"><?php 
    echo wpsc_cart_total();
    ?>
</span>
		</td>
	</tr>
	
	
	</table>

		<?php 
    do_action('wpsc_before_form_of_shopping_cart');
    ?>
	
	<form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
	
	   <?php 
開發者ID:papayalabs,項目名稱:htdocs,代碼行數:31,代碼來源:shopping_cart_page.php

示例3: wpsc_change_tax

/**
	* wpsc_change_tax function, used through ajax and in normal page loading.
	* No parameters, returns nothing
*/
function wpsc_change_tax()
{
    global $wpdb, $wpsc_cart, $wpsc_theme_path;
    $form_id = absint($_POST['form_id']);
    $wpsc_selected_country = $wpsc_cart->selected_country;
    $wpsc_selected_region = $wpsc_cart->selected_region;
    $wpsc_delivery_country = $wpsc_cart->delivery_country;
    $wpsc_delivery_region = $wpsc_cart->delivery_region;
    $previous_country = $_SESSION['wpsc_selected_country'];
    if (isset($_POST['billing_country'])) {
        $wpsc_selected_country = $wpdb->escape($_POST['billing_country']);
        $_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
    }
    if (isset($_POST['billing_region'])) {
        $wpsc_selected_region = absint($_POST['billing_region']);
        $_SESSION['wpsc_selected_region'] = $wpsc_selected_region;
    }
    //if(!wpsc_has_shipping_form()) {
    //	$_POST['shipping_country'] = $wpsc_selected_country;
    //	$_POST['shipping_region'] = $wpsc_selected_region;
    //}
    $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $_SESSION['wpsc_selected_region'] . "' LIMIT 1");
    if ($_SESSION['wpsc_selected_country'] != $check_country_code) {
        $wpsc_selected_region = null;
    }
    if (isset($_POST['shipping_country'])) {
        $wpsc_delivery_country = $wpdb->escape($_POST['shipping_country']);
        $_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country;
    }
    if (isset($_POST['shipping_region'])) {
        $wpsc_delivery_region = absint($_POST['shipping_region']);
        $_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
    }
    $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $wpsc_delivery_region . "' LIMIT 1");
    if ($wpsc_delivery_country != $check_country_code) {
        $wpsc_delivery_region = null;
    }
    $wpsc_cart->update_location();
    $wpsc_cart->get_shipping_method();
    $wpsc_cart->get_shipping_option();
    if ($wpsc_cart->selected_shipping_method != '') {
        $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
    }
    $tax = $wpsc_cart->calculate_total_tax();
    $total = wpsc_cart_total();
    ob_start();
    $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder', $wpsc_theme_path . WPSC_THEME_DIR);
    include_once $cur_wpsc_theme_folder . "/cart_widget.php";
    $output = ob_get_contents();
    ob_end_clean();
    //exit("/*<pre>".print_r($wpsc_cart,true)."</pre>*/");
    $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
    if (get_option('lock_tax') == 1) {
        //echo "jQuery('#region').val(".$_SESSION['wpsc_delivery_region']."); \n";
        echo "jQuery('#current_country').val('" . $_SESSION['wpsc_delivery_country'] . "'); \n";
        if ($_SESSION['wpsc_delivery_country'] == 'US' && get_option('lock_tax') == 1) {
            //exit('<pre>'.print_r($_SESSION, true).'</pre>');
            $output = wpsc_shipping_region_list($_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region']);
            //	echo 'jQuery("#change_country").append(\''.$output.'\');\n\r';
            $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
            echo "jQuery('#region').remove();\n\r";
            echo "jQuery('#change_country').append(\"" . $output . "\");\n\r";
        }
    }
    foreach ($wpsc_cart->cart_items as $key => $cart_item) {
        echo "jQuery('#shipping_{$key}').html(\"" . $wpsc_cart->process_as_currency($cart_item->shipping) . "\");\n\r";
    }
    echo "jQuery('#checkout_shipping').html(\"" . wpsc_cart_shipping() . "\");\n\r";
    echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n";
    if (get_option('lock_tax') == 1) {
        echo "jQuery('.shipping_country').val('" . $_SESSION['wpsc_delivery_country'] . "') \n";
        $sql = "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $_SESSION['wpsc_selected_country'] . "'";
        $country_name = $wpdb->get_var($sql);
        echo "jQuery('.shipping_country_name').html('" . $country_name . "') \n";
    }
    $form_selected_country = null;
    $form_selected_region = null;
    $onchange_function = null;
    if ($_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) {
        $form_selected_country = $wpsc_selected_country;
        $form_selected_region = $wpsc_selected_region;
        $onchange_function = 'set_billing_country';
        $title = 'billingregion';
    } else {
        if ($_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) {
            $form_selected_country = $wpsc_delivery_country;
            $form_selected_region = $wpsc_delivery_region;
            $onchange_function = 'set_shipping_country';
            $title = 'shippingregion';
        }
    }
    if ($form_selected_country != null && $onchange_function != null) {
        $region_list = $wpdb->get_results("SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "`  WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $form_selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A);
        if ($region_list != null) {
            $output = "<select title='{$title}' name='collected_data[" . $form_id . "][1]' class='current_region' onchange='{$onchange_function}(\"region_country_form_{$form_id}\", \"{$form_id}\");'>\n\r";
            foreach ($region_list as $region) {
//.........這裏部分代碼省略.........
開發者ID:alx,項目名稱:SBek-Arak,代碼行數:101,代碼來源:ajax.functions.php

示例4: __

			<?php echo __('Discount', 'wpsc'); ?>
		</td>
		<td colspan="2">
			<span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
	    </td>
   	</tr>
	  <?php endif ?>

		
	
	<tr class='total_price'>
		<td colspan='3'>
		<?php echo __('Total Price', 'wpsc'); ?>
		</td>
		<td colspan='2'>
			<span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
		</td>
	</tr>
	
	
	</table>

		<?php do_action('wpsc_before_form_of_shopping_cart'); ?>
	
	<form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
	
	   <?php 
	   /**  
	    * Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
	   */
	   ?>
開發者ID:nerdfiles,項目名稱:sideshowtramps.com,代碼行數:31,代碼來源:shopping_cart_page.php

示例5: paypal_processingfunctions


//.........這裏部分代碼省略.........
                    $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType . "&ReturnUrl=" . $returnURL . "&CANCELURL=" . $cancelURL . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
                    /* Make the call to PayPal to set the Express Checkout token
                    			If the API call succeded, then redirect the buyer to PayPal
                    			to begin to authorize payment.  If an error occured, show the
                    			resulting errors
                    			*/
                    $resArray = paypal_hash_call("SetExpressCheckout", $nvpstr);
                    wpsc_update_customer_meta('paypal_express_reshash', $resArray);
                    $ack = strtoupper($resArray["ACK"]);
                    if ($ack == "SUCCESS") {
                        // Redirect to paypal.com here
                        $token = urldecode($resArray["TOKEN"]);
                        $payPalURL = $PAYPAL_URL . $token;
                        wp_redirect($payPalURL);
                    } else {
                        // Redirecting to APIError.php to display errors.
                        $location = get_option('transact_url') . "&act=error";
                        wp_redirect($location);
                    }
                    exit;
                } else {
                    /* At this point, the buyer has completed in authorizing payment
                    			at PayPal.  The script will now call PayPal with the details
                    			of the authorization, incuding any shipping information of the
                    			buyer.  Remember, the authorization is not a completed transaction
                    			at this state - the buyer still needs an additional step to finalize
                    			the transaction
                    			*/
                    $token = urlencode($_REQUEST['token']);
                    /* Build a second API request to PayPal, using the token as the
                    			ID to get the details on the payment authorization
                    			*/
                    $nvpstr = "&TOKEN=" . $token;
                    /* Make the API call and store the results in an array.  If the
                    			call was a success, show the authorization details, and provide
                    			an action to complete the payment.  If failed, show the error
                    			*/
                    $resArray = paypal_hash_call("GetExpressCheckoutDetails", $nvpstr);
                    wpsc_update_customer_meta('paypal_express_reshash', $resArray);
                    $ack = strtoupper($resArray["ACK"]);
                    if ($ack == "SUCCESS") {
                        /********************************************************
                        				GetExpressCheckoutDetails.php
                        
                        				This functionality is called after the buyer returns from
                        				PayPal and has authorized the payment.
                        
                        				Displays the payer details returned by the
                        				GetExpressCheckoutDetails response and calls
                        				DoExpressCheckoutPayment.php to complete the payment
                        				authorization.
                        
                        				Called by ReviewOrder.php.
                        
                        				Calls DoExpressCheckoutPayment.php and APIError.php.
                        
                        				********************************************************/
                        /* Collect the necessary information to complete the
                        			authorization for the PayPal payment
                        			*/
                        /* Display the API response back to the browser .
                        			If the response from PayPal was a success, display the response parameters
                        			*/
                        if (isset($_REQUEST['token']) && !isset($_REQUEST['PayerID'])) {
                            wpsc_update_customer_meta('paypal_express_message', _x('<h4>TRANSACTION CANCELED</h4>', 'paypal express cancel header', 'wpsc'));
                        } else {
                            wpsc_update_customer_meta('paypal_express_token', $_REQUEST['token']);
                            wpsc_update_customer_meta('paypal_express_payer_id', $_REQUEST['PayerID']);
                            $resArray = wpsc_get_customer_meta('paypal_express_reshash');
                            if (get_option('permalink_structure') != '') {
                                $separator = "?";
                            } else {
                                $separator = "&";
                            }
                            if (!isset($resArray['SHIPTOSTREET2'])) {
                                $resArray['SHIPTOSTREET2'] = '';
                            }
                            $output = "\n\t\t\t\t\t   <table width='400' class='paypal_express_form'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'><b>" . __('Order Total:', 'wpsc') . "</b></td>\n\t\t\t\t\t\t\t<td align='left'>" . wpsc_currency_display(wpsc_get_customer_meta('paypal_express_original_amount')) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' colspan='2'><b>" . __('Shipping Address:', 'wpsc') . " </b></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Street 1:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOSTREET'] . "</td>\n\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Street 2:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOSTREET2'] . "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('City:', 'wpsc') . "</td>\n\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOCITY'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('State:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOSTATE'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Postal code:', 'wpsc') . "</td>\n\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOZIP'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='firstcol'>\n\t\t\t\t\t\t\t\t" . __('Country:', 'wpsc') . "</td>\n\t\t\t\t\t\t\t<td align='left'>" . $resArray['SHIPTOCOUNTRYNAME'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2'>";
                            $output .= "<form action=" . get_option('transact_url') . " method='post'>\n";
                            $output .= "\t<input type='hidden' name='totalAmount' value='" . wpsc_cart_total(false) . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingStreet' value='" . $resArray['SHIPTOSTREET'] . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingStreet2' value='" . $resArray['SHIPTOSTREET2'] . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingCity' value='" . $resArray['SHIPTOCITY'] . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingState' value='" . $resArray['SHIPTOSTATE'] . "' />\n";
                            $output .= "\t<input type='hidden' name='postalCode' value='" . $resArray['SHIPTOZIP'] . "' />\n";
                            $output .= "\t<input type='hidden' name='country' value='" . $resArray['SHIPTOCOUNTRYNAME'] . "' />\n";
                            $output .= "\t<input type='hidden' name='token' value='" . wpsc_get_customer_meta('paypal_express_token') . "' />\n";
                            $output .= "\t<input type='hidden' name='PayerID' value='" . wpsc_get_customer_meta('paypal_express_payer_id') . "' />\n";
                            $output .= "\t<input type='hidden' name='act' value='do' />\n";
                            $output .= "\t<p>  <input name='usePayPal' type='submit' value='" . __('Confirm Payment', 'wpsc') . "' /></p>\n";
                            $output .= "</form>";
                            $output .= " </td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</center>\n\t\t\t\t\t";
                            wpsc_update_customer_meta('paypal_express_message', $output);
                        }
                    }
                }
            }
        }
    }
}
開發者ID:dreamteam111,項目名稱:dreamteam,代碼行數:101,代碼來源:paypal-express.merchant.php

示例6: wpsc_change_tax

/**
 * wpsc_change_tax function, used through ajax and in normal page loading.
 * No parameters, returns nothing
 */
function wpsc_change_tax()
{
    global $wpdb, $wpsc_cart;
    $form_id = absint($_POST['form_id']);
    $wpsc_selected_country = $wpsc_cart->selected_country;
    $wpsc_selected_region = $wpsc_cart->selected_region;
    $wpsc_delivery_country = $wpsc_cart->delivery_country;
    $wpsc_delivery_region = $wpsc_cart->delivery_region;
    $previous_country = $_SESSION['wpsc_selected_country'];
    if (isset($_POST['billing_country'])) {
        $wpsc_selected_country = $wpdb->escape($_POST['billing_country']);
        $_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
    }
    if (isset($_POST['billing_region'])) {
        $wpsc_selected_region = absint($_POST['billing_region']);
        $_SESSION['wpsc_selected_region'] = $wpsc_selected_region;
    }
    $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $_SESSION['wpsc_selected_region'] . "' LIMIT 1");
    if ($_SESSION['wpsc_selected_country'] != $check_country_code) {
        $wpsc_selected_region = null;
    }
    if (isset($_POST['shipping_country'])) {
        $wpsc_delivery_country = $wpdb->escape($_POST['shipping_country']);
        $_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country;
    }
    if (isset($_POST['shipping_region'])) {
        $wpsc_delivery_region = absint($_POST['shipping_region']);
        $_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
    }
    $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $wpsc_delivery_region . "' LIMIT 1");
    if ($wpsc_delivery_country != $check_country_code) {
        $wpsc_delivery_region = null;
    }
    $wpsc_cart->update_location();
    $wpsc_cart->get_shipping_method();
    $wpsc_cart->get_shipping_option();
    if ($wpsc_cart->selected_shipping_method != '') {
        $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
    }
    $tax = $wpsc_cart->calculate_total_tax();
    $total = wpsc_cart_total();
    $total_input = wpsc_cart_total(false);
    if ($wpsc_cart->coupons_amount >= wpsc_cart_total() && !empty($wpsc_cart->coupons_amount)) {
        $total = 0;
    }
    if ($wpsc_cart->total_price < 0) {
        $wpsc_cart->coupons_amount += $wpsc_cart->total_price;
        $wpsc_cart->total_price = null;
        $wpsc_cart->calculate_total_price();
    }
    ob_start();
    include_once wpsc_get_template_file_path('wpsc-cart_widget.php');
    $output = ob_get_contents();
    ob_end_clean();
    $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
    if (get_option('lock_tax') == 1) {
        echo "jQuery('#current_country').val('" . $_SESSION['wpsc_delivery_country'] . "'); \n";
        if ($_SESSION['wpsc_delivery_country'] == 'US' && get_option('lock_tax') == 1) {
            $output = wpsc_shipping_region_list($_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region']);
            $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
            echo "jQuery('#region').remove();\n\r";
            echo "jQuery('#change_country').append(\"" . $output . "\");\n\r";
        }
    }
    foreach ($wpsc_cart->cart_items as $key => $cart_item) {
        echo "jQuery('#shipping_{$key}').html(\"" . wpsc_currency_display($cart_item->shipping) . "\");\n\r";
    }
    echo "jQuery('#checkout_shipping').html(\"" . wpsc_cart_shipping() . "\");\n\r";
    echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n";
    if (get_option('lock_tax') == 1) {
        echo "jQuery('.shipping_country').val('" . $_SESSION['wpsc_delivery_country'] . "') \n";
        $sql = "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $_SESSION['wpsc_selected_country'] . "'";
        $country_name = $wpdb->get_var($sql);
        echo "jQuery('.shipping_country_name').html('" . $country_name . "') \n";
    }
    $form_selected_country = null;
    $form_selected_region = null;
    $onchange_function = null;
    if ($_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) {
        $form_selected_country = $wpsc_selected_country;
        $form_selected_region = $wpsc_selected_region;
        $onchange_function = 'set_billing_country';
    } else {
        if ($_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) {
            $form_selected_country = $wpsc_delivery_country;
            $form_selected_region = $wpsc_delivery_region;
            $onchange_function = 'set_shipping_country';
        }
    }
    if ($form_selected_country != null && $onchange_function != null) {
        $region_list = $wpdb->get_results("SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "`  WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $form_selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A);
        if ($region_list != null) {
            $title = empty($_POST['billing_country']) ? 'shippingstate' : 'billingstate';
            $output = "<select name='collected_data[" . $form_id . "][1]' class='current_region' onchange='{$onchange_function}(\"region_country_form_{$form_id}\", \"{$form_id}\");' title='" . $title . "'>\n\r";
            foreach ($region_list as $region) {
                if ($form_selected_region == $region['id']) {
//.........這裏部分代碼省略.........
開發者ID:hornet9,項目名稱:Morato,代碼行數:101,代碼來源:ajax.functions.php

示例7: wpsc_is_free_cart

/**
 * Checks if the current cart is a "Free Cart", which means one of the following:
 *
 *  - Either the all of the cart items are priced at 0.
 *  - Or a coupon has been applied that results in a free cart.
 *
 * This is a helpful function for doing things like allowing free carts to be purchased, bypassing payment gateways.
 *
 * @since  3.9.0
 * @return bool Whether or not the current cart's total cost is free or not.
 */
function wpsc_is_free_cart()
{
    return apply_filters('wpsc_is_free_cart', wpsc_cart_item_count() && !floatval(wpsc_cart_total(false)));
}
開發者ID:parkesma,項目名稱:WP-e-Commerce,代碼行數:15,代碼來源:cart-template-api.php

示例8: wpsc_change_tax

/**
 * wpsc_change_tax function, used through ajax and in normal page loading.
 * No parameters, returns nothing
 */
function wpsc_change_tax()
{
    global $wpdb, $wpsc_cart;
    $form_id = absint($_POST['form_id']);
    $wpsc_selected_country = $wpsc_cart->selected_country;
    $wpsc_selected_region = $wpsc_cart->selected_region;
    $wpsc_delivery_country = $wpsc_cart->delivery_country;
    $wpsc_delivery_region = $wpsc_cart->delivery_region;
    $previous_country = wpsc_get_customer_meta('billingcountry');
    global $wpdb, $user_ID, $wpsc_customer_checkout_details;
    if (isset($_POST['billing_country'])) {
        $wpsc_selected_country = $_POST['billing_country'];
        wpsc_update_customer_meta('billingcountry', $wpsc_selected_country);
    }
    if (isset($_POST['billing_region'])) {
        $wpsc_selected_region = absint($_POST['billing_region']);
        wpsc_update_customer_meta('billingregion', $wpsc_selected_region);
    }
    $check_country_code = WPSC_Countries::country_id(wpsc_get_customer_meta('billing_region'));
    if (wpsc_get_customer_meta('billingcountry') != $check_country_code) {
        $wpsc_selected_region = null;
    }
    if (isset($_POST['shipping_country'])) {
        $wpsc_delivery_country = $_POST['shipping_country'];
        wpsc_update_customer_meta('shippingcountry', $wpsc_delivery_country);
    }
    if (isset($_POST['shipping_region'])) {
        $wpsc_delivery_region = absint($_POST['shipping_region']);
        wpsc_update_customer_meta('shippingregion', $wpsc_delivery_region);
    }
    $check_country_code = WPSC_Countries::country_id($wpsc_delivery_region);
    if ($wpsc_delivery_country != $check_country_code) {
        $wpsc_delivery_region = null;
    }
    $wpsc_cart->update_location();
    $wpsc_cart->get_shipping_method();
    $wpsc_cart->get_shipping_option();
    if ($wpsc_cart->selected_shipping_method != '') {
        $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
    }
    $tax = $wpsc_cart->calculate_total_tax();
    $total = wpsc_cart_total();
    $total_input = wpsc_cart_total(false);
    if ($wpsc_cart->coupons_amount >= $total_input && !empty($wpsc_cart->coupons_amount)) {
        $total = 0;
    }
    if ($wpsc_cart->total_price < 0) {
        $wpsc_cart->coupons_amount += $wpsc_cart->total_price;
        $wpsc_cart->total_price = null;
        $wpsc_cart->calculate_total_price();
    }
    $delivery_country = wpsc_get_customer_meta('shipping_country');
    $output = _wpsc_ajax_get_cart(false);
    $output = $output['widget_output'];
    $json_response = array();
    global $wpsc_checkout;
    if (empty($wpsc_checkout)) {
        $wpsc_checkout = new wpsc_checkout();
    }
    $json_response['delivery_country'] = esc_js($delivery_country);
    $json_response['billing_country'] = esc_js($wpsc_selected_country);
    $json_response['widget_output'] = $output;
    $json_response['shipping_keys'] = array();
    $json_response['cart_shipping'] = wpsc_cart_shipping();
    $json_response['form_id'] = $form_id;
    $json_response['tax'] = $tax;
    $json_response['display_tax'] = wpsc_cart_tax();
    $json_response['total'] = $total;
    $json_response['total_input'] = $total_input;
    $json_response['lock_tax'] = get_option('lock_tax');
    $json_response['country_name'] = wpsc_get_country($delivery_country);
    if ('US' == $delivery_country || 'CA' == $delivery_country) {
        $output = wpsc_shipping_region_list($delivery_country, wpsc_get_customer_meta('shipping_region'));
        $output = str_replace(array("\n", "\r"), '', $output);
        $json_response['shipping_region_list'] = $output;
    }
    foreach ($wpsc_cart->cart_items as $key => $cart_item) {
        $json_response['shipping_keys'][$key] = wpsc_currency_display($cart_item->shipping);
    }
    $form_selected_country = null;
    $form_selected_region = null;
    $onchange_function = null;
    if (!empty($_POST['billing_country']) && $_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) {
        $form_selected_country = $wpsc_selected_country;
        $form_selected_region = $wpsc_selected_region;
        $onchange_function = 'set_billing_country';
    } else {
        if (!empty($_POST['shipping_country']) && $_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) {
            $form_selected_country = $wpsc_delivery_country;
            $form_selected_region = $wpsc_delivery_region;
            $onchange_function = 'set_shipping_country';
        }
    }
    if ($form_selected_country != null && $onchange_function != null) {
        $checkoutfields = 'set_shipping_country' == $onchange_function;
        $region_list = wpsc_country_region_list($form_id, false, $form_selected_country, $form_selected_region, $form_id, $checkoutfields);
//.........這裏部分代碼省略.........
開發者ID:dreamteam111,項目名稱:dreamteam,代碼行數:101,代碼來源:ajax.php

示例9: validate_forms

 /**
  * validate_forms method, validates the input from the checkout page
  * @access public
  */
 function validate_forms()
 {
     global $wpdb, $current_user, $user_ID;
     $any_bad_inputs = false;
     // Credit Card Number Validation for Paypal Pro and maybe others soon
     if (wpsc_cart_total(false) != 0) {
         if (isset($_POST['card_number'])) {
             if ($_POST['card_number'] != '') {
                 /*
                 
                    			$ccregex='/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/';
                    			if(!preg_match($ccregex, $_POST['card_number'])){
                    				$any_bad_inputs = true;
                 				$bad_input = true;
                 				$_SESSION['wpsc_gateway_error_messages']['card_number'] = __('Please enter a valid', 'wpsc') . " " . strtolower('card number') . ".";
                 				$_SESSION['wpsc_checkout_saved_values']['card_number'] = '';
                    			}else{
                    				$_SESSION['wpsc_gateway_error_messages']['card_number'] = '';
                    			}   		
                 */
             } else {
                 $any_bad_inputs = true;
                 $bad_input = true;
                 $_SESSION['wpsc_gateway_error_messages']['card_number'] = __('Please enter a valid', 'wpsc') . " " . strtolower('card number') . ".";
                 $_SESSION['wpsc_checkout_saved_values']['card_number'] = '';
             }
         } else {
             $_SESSION['wpsc_gateway_error_messages']['card_number'] = '';
         }
         if (isset($_POST['card_number1']) && isset($_POST['card_number2']) && isset($_POST['card_number3']) && isset($_POST['card_number4'])) {
             if ($_POST['card_number1'] != '' && $_POST['card_number2'] != '' && $_POST['card_number3'] != '' && $_POST['card_number4'] != '' && is_numeric($_POST['card_number1']) && is_numeric($_POST['card_number2']) && is_numeric($_POST['card_number3']) && is_numeric($_POST['card_number4'])) {
                 $_SESSION['wpsc_gateway_error_messages']['card_number'] = '';
             } else {
                 $any_bad_inputs = true;
                 $bad_input = true;
                 $_SESSION['wpsc_gateway_error_messages']['card_number'] = __('Please enter a valid', 'wpsc') . " " . strtolower('card number') . ".";
                 $_SESSION['wpsc_checkout_saved_values']['card_number'] = '';
             }
         }
         if (isset($_POST['expiry'])) {
             if ($_POST['expiry']['month'] != '' && $_POST['expiry']['month'] != '' && is_numeric($_POST['expiry']['month']) && is_numeric($_POST['expiry']['year'])) {
                 $_SESSION['wpsc_gateway_error_messages']['expdate'] = '';
             } else {
                 $any_bad_inputs = true;
                 $bad_input = true;
                 $_SESSION['wpsc_gateway_error_messages']['expdate'] = __('Please enter a valid', 'wpsc') . " " . strtolower('Expiry Date') . ".";
                 $_SESSION['wpsc_checkout_saved_values']['expdate'] = '';
             }
         }
         if (isset($_POST['card_code'])) {
             if ($_POST['card_code'] == '' || !is_numeric($_POST['card_code'])) {
                 $any_bad_inputs = true;
                 $bad_input = true;
                 $_SESSION['wpsc_gateway_error_messages']['card_code'] = __('Please enter a valid', 'wpsc') . " " . strtolower('CVV') . ".";
                 $_SESSION['wpsc_checkout_saved_values']['card_code'] = '';
             } else {
                 $_SESSION['wpsc_gateway_error_messages']['card_code'] = '';
             }
         }
         if (isset($_POST['cctype'])) {
             if ($_POST['cctype'] == '') {
                 $any_bad_inputs = true;
                 $bad_input = true;
                 $_SESSION['wpsc_gateway_error_messages']['cctype'] = __('Please enter a valid', 'wpsc') . " " . strtolower('CVV') . ".";
                 $_SESSION['wpsc_checkout_saved_values']['cctype'] = '';
             } else {
                 $_SESSION['wpsc_gateway_error_messages']['cctype'] = '';
             }
         }
     }
     //closes main bracket
     if (isset($_POST['log']) || isset($_POST['pwd']) || isset($_POST['user_email'])) {
         $results = wpsc_add_new_user($_POST['log'], $_POST['pwd'], $_POST['user_email']);
         $_SESSION['wpsc_checkout_user_error_messages'] = array();
         if (is_callable(array($results, "get_error_code")) && $results->get_error_code()) {
             foreach ($results->get_error_codes() as $code) {
                 foreach ($results->get_error_messages($code) as $error) {
                     $_SESSION['wpsc_checkout_user_error_messages'][] = $error;
                 }
                 $any_bad_inputs = true;
             }
         }
         //exit('<pre>'.print_r($results, true).'</pre>');
         if ($results->ID > 0) {
             $our_user_id = $results->ID;
         } else {
             $any_bad_inputs = true;
         }
     }
     if ($our_user_id < 1) {
         $our_user_id = $user_ID;
     }
     // check we have a user id
     if ($our_user_id > 0) {
         $user_ID = $our_user_id;
     }
//.........這裏部分代碼省略.........
開發者ID:kasima,項目名稱:wp-e-commerce-ezp,代碼行數:101,代碼來源:checkout.class.php

示例10: compare_logic


//.........這裏部分代碼省略.........
                     }
                     break;
                 case 'less':
                     //Checks if the quantity of a product is less than the condition value
                     if ($product_obj->quantity < $c['value']) {
                         return true;
                     }
                     break;
                 case 'contains':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'not_contain':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (empty($match)) {
                         return true;
                     }
                     break;
                 case 'begins':
                     //Checks if the product name begins with condition value
                     preg_match("/^" . $c['value'] . "/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'ends':
                     //Checks if the product name ends with condition value
                     preg_match("/" . $c['value'] . "\$/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 default:
                     return false;
             }
         } else {
             if ($c['property'] == 'total_quantity') {
                 //			exit('<pre>'.print_r($product_obj, true).'</pre>');
                 $total_quantity = $product_obj->quantity;
                 switch ($c['logic']) {
                     case 'equal':
                         //Checks if the quantity of products in the cart equals condition value
                         if ($total_quantity == $c['value']) {
                             return true;
                         }
                         break;
                     case 'greater':
                         //Checks if the quantity in the cart is greater than the condition value
                         if ($total_quantity > $c['value']) {
                             return true;
                         }
                         break;
                     case 'less':
                         //Checks if the quantity in the cart is less than the condition value
                         if ($total_quantity < $c['value']) {
                             return true;
                         }
                         break;
                     default:
                         return false;
                 }
             } else {
                 if ($c['property'] == 'subtotal_amount') {
                     $subtotal = wpsc_cart_total(false);
                     //exit('<pre>'.print_r($subtotal,true).'</pre>');
                     switch ($c['logic']) {
                         case 'equal':
                             //Checks if the subtotal of products in the cart equals condition value
                             if ($subtotal == $c['value']) {
                                 return true;
                             }
                             break;
                         case 'greater':
                             //Checks if the subtotal of the cart is greater than the condition value
                             //	exit('triggered here'.$subtotal.'>'.$c['value']);
                             if ($subtotal > $c['value']) {
                                 return true;
                             }
                             break;
                         case 'less':
                             //Checks if the subtotal of the cart is less than the condition value
                             if ($subtotal < $c['value']) {
                                 //exit('<pre>'.print_r($product_obj->cart->subtotal, true).'</pre>cValue'.$c['value']);
                                 return true;
                             } else {
                                 return false;
                             }
                             break;
                         default:
                             return false;
                     }
                 }
             }
         }
     }
 }
開發者ID:papayalabs,項目名稱:htdocs,代碼行數:101,代碼來源:coupons.class.php

示例11: gateway_paypal_payflow

function gateway_paypal_payflow($seperator, $sessionid)
{
    global $wpdb, $wpsc_cart;
    $purchase_log_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1";
    $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A);
    $fraud = 'NO';
    $env = get_option('paypal_payflow_test') ? 'Test' : 'Live';
    $user = get_option('paypal_payflow_user');
    $password = get_option('paypal_payflow_pass');
    $partner = get_option('paypal_payflow_partner');
    $vendor = get_option('paypal_payflow_vendor');
    $currency = get_option('paypal_payflow_curcode');
    if ($env == 'Live') {
        $submiturl = 'https://payflowpro.paypal.com';
        $PayPalURL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
    } else {
        $submiturl = 'https://pilot-payflowpro.paypal.com';
        $PayPalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
    }
    $cart_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='" . $purchase_log[0]['id'] . "'";
    $cart = $wpdb->get_results($cart_sql, ARRAY_A);
    $member_subtype = get_product_meta($cart[0]['prodid'], 'is_permenant', true);
    $member_shiptype = get_product_meta($cart[0]['prodid'], 'membership_length', true);
    $member_shiptype = $member_shiptype[0];
    $status = get_product_meta($cart[0]['prodid'], 'is_membership', true);
    $is_member = $status;
    $is_perm = $member_subtype;
    $length = $member_shiptype['length'];
    $custom = $purchase_log[0]['id'];
    if ($_POST['collected_data'][get_option('paypal_form_first_name')] != '') {
        $data['first_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_first_name')]);
    }
    if ($_POST['collected_data'][get_option('paypal_form_last_name')] != '') {
        $data['last_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_last_name')]);
    }
    if ($_POST['collected_data'][get_option('paypal_form_address')] != '') {
        $address_rows = explode("\n\r", $_POST['collected_data'][get_option('paypal_form_address')]);
        $data['address1'] = urlencode(str_replace(array("\n", "\r"), '', $address_rows[0]));
        unset($address_rows[0]);
        if ($address_rows != null) {
            $data['address2'] = implode(", ", $address_rows);
        } else {
            $data['address2'] = '';
        }
    }
    if ($_POST['collected_data'][get_option('paypal_form_city')] != '') {
        $data['city'] = urlencode($_POST['collected_data'][get_option('paypal_form_city')]);
    }
    if ($_POST['collected_data'][get_option('paypal_form_state')] != '') {
        $data['state'] = $wpdb->get_var("SELECT code FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE id='" . wpsc_get_customer_meta('billing_region') . "'");
    }
    $customer_billing_country = wpsc_get_customer_meta('billing_country');
    if (preg_match("/^[a-zA-Z]{2}\$/", $customer_billing_country)) {
        $data['country'] = $customer_billing_country;
    }
    if (is_numeric($_POST['collected_data'][get_option('paypal_form_post_code')])) {
        $data['zip'] = urlencode($_POST['collected_data'][get_option('paypal_form_post_code')]);
    }
    $email_data = $wpdb->get_results("SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1'", ARRAY_A);
    foreach ((array) $email_data as $email) {
        $data['email'] = $_POST['collected_data'][$email['id']];
    }
    if ($_POST['collected_data'][get_option('email_form_field')] != null && $data['email'] == null) {
        $data['email'] = $_POST['collected_data'][get_option('email_form_field')];
    }
    $card_num = $_POST['card_number'];
    $cvv2 = $_POST['card_cvv'];
    $expiry = $_POST['expiry']['month'] . $_POST['expiry']['year'];
    $unique_id = generateGUID();
    $fname = $data['first_name'];
    $lname = $data['last_name'];
    $addr1 = $data['address1'] . $data['address2'];
    $addr2 = $data['city'];
    $addr3 = $data['state'];
    $addr4 = $data['zip'];
    $country = $data['country'];
    $email = $data['email'];
    $amount = wpsc_cart_total(false);
    $amount = number_format($amount, 2, '.', '');
    if ($is_member[0]) {
        switch ($member_shiptype['unit']) {
            case 'w':
                $member_ship_unit = 'WEEK';
                break;
            case 'm':
                $member_ship_unit = 'MONT';
                break;
            case 'y':
                $member_ship_unit = 'YEAR';
                break;
        }
        $paypal_query_array = array('USER' => $user, 'PROFILENAME' => $fname . $lname . $purchase_log[0]['id'], 'VENDOR' => $vendor, 'PARTNER' => $partner, 'PWD' => $password, 'TENDER' => 'C', 'TRXTYPE' => 'R', 'ACTION' => 'A', 'START' => date('m') . (date('d') + 1) . date('Y'), 'ACCT' => $card_num, 'CVV2' => $cvv2, 'EXPDATE' => $expiry, 'ACCTTYPE' => $card, 'AMT' => $amount, 'CURRENCY' => $currency, 'FIRSTNAME' => $fname, 'LASTNAME' => $lname, 'STREET' => $addr1, 'CITY' => $addr2, 'STATE' => $addr3, 'ZIP' => $addr4, 'COUNTRY' => $country, 'EMAIL' => $email, 'OPTIONALTRX' => 'A', 'OPTIONALTRXAMT' => '0.00', 'CLIENTIP' => $cust_ip, 'COMMENT1' => $custom, 'ORDERDESC' => $fname . $lname . $purchase_log[0]['id'], 'PAYPERIOD' => $member_ship_unit);
        foreach ($paypal_query_array as $key => $value) {
            if ($key == 'USER') {
                $paypal_query .= $key . '[' . strlen($value) . ']=' . $value;
            } else {
                $paypal_query .= '&' . $key . '[' . strlen($value) . ']=' . $value;
            }
        }
        $response = fetch_data($unique_id, $submiturl, $paypal_query);
//.........這裏部分代碼省略.........
開發者ID:benhuson,項目名稱:Gold-Cart,代碼行數:101,代碼來源:paypal_payflowpro.php

示例12: processingfunctions


//.........這裏部分代碼省略.........
                    if (get_option('permalink_structure') != '') {
                        $seperator = "?";
                    } else {
                        $seperator = "&";
                    }
                    $returnURL = urlencode(get_option('transact_url') . $seperator . 'currencyCodeType=' . $currencyCodeType . '&paymentType=' . $paymentType . '&paymentAmount=' . $paymentAmount);
                    $cancelURL = urlencode(get_option('transact_url') . $seperator . 'paymentType=$paymentType');
                    /* Construct the parameter string that describes the PayPal payment
                    			the varialbes were set in the web form, and the resulting string
                    			is stored in $nvpstr
                    			*/
                    $nvpstr = "&Amt=" . $paymentAmount . "&PAYMENTACTION=" . $paymentType . "&ReturnUrl=" . $returnURL . "&CANCELURL=" . $cancelURL . "&CURRENCYCODE=" . $currencyCodeType;
                    /* Make the call to PayPal to set the Express Checkout token
                    			If the API call succeded, then redirect the buyer to PayPal
                    			to begin to authorize payment.  If an error occured, show the
                    			resulting errors
                    			*/
                    $resArray = hash_call("SetExpressCheckout", $nvpstr);
                    $_SESSION['reshash'] = $resArray;
                    $ack = strtoupper($resArray["ACK"]);
                    if ($ack == "SUCCESS") {
                        // Redirect to paypal.com here
                        $token = urldecode($resArray["TOKEN"]);
                        $payPalURL = PAYPAL_URL . $token;
                        header("Location: " . $payPalURL);
                    } else {
                        //Redirecting to APIError.php to display errors.
                        $location = get_option('transact_url') . "&act=error";
                        header("Location: {$location}");
                    }
                    exit;
                } else {
                    /* At this point, the buyer has completed in authorizing payment
                    		at PayPal.  The script will now call PayPal with the details
                    		of the authorization, incuding any shipping information of the
                    		buyer.  Remember, the authorization is not a completed transaction
                    		at this state - the buyer still needs an additional step to finalize
                    		the transaction
                    		*/
                    $token = urlencode($_REQUEST['token']);
                    /* Build a second API request to PayPal, using the token as the
                    		ID to get the details on the payment authorization
                    		*/
                    $nvpstr = "&TOKEN=" . $token;
                    /* Make the API call and store the results in an array.  If the
                    		call was a success, show the authorization details, and provide
                    		an action to complete the payment.  If failed, show the error
                    		*/
                    $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr);
                    $_SESSION['reshash'] = $resArray;
                    $ack = strtoupper($resArray["ACK"]);
                    if ($ack == "SUCCESS") {
                        /********************************************************
                        GetExpressCheckoutDetails.php
                        
                        This functionality is called after the buyer returns from
                        PayPal and has authorized the payment.
                        
                        Displays the payer details returned by the
                        GetExpressCheckoutDetails response and calls
                        DoExpressCheckoutPayment.php to complete the payment
                        authorization.
                        
                        Called by ReviewOrder.php.
                        
                        Calls DoExpressCheckoutPayment.php and APIError.php.
                        
                        ********************************************************/
                        session_start();
                        /* Collect the necessary information to complete the
                           authorization for the PayPal payment
                           */
                        $_SESSION['token'] = $_REQUEST['token'];
                        $_SESSION['payer_id'] = $_REQUEST['PayerID'];
                        /*
                        $_SESSION['paymentAmount']=$_REQUEST['paymentAmount'];
                        $_SESSION['currCodeType']=$_REQUEST['currencyCodeType'];
                        $_SESSION['paymentType']=$_REQUEST['paymentType'];
                        */
                        $resArray = $_SESSION['reshash'];
                        if (get_option('permalink_structure') != '') {
                            $seperator = "?";
                        } else {
                            $seperator = "&";
                        }
                        /* Display the  API response back to the browser .
                           If the response from PayPal was a success, display the response parameters
                           */
                        if (isset($_REQUEST['token']) && !isset($_REQUEST['PayerID'])) {
                            $_SESSION['paypalExpressMessage'] = '<h4>TRANSACTION CANCELED</h4>';
                        } else {
                            $_SESSION['paypalExpressMessage'] = "\n\t<form action=" . get_option('transact_url') . " method='post'>\n           <table width='400'>\n            <tr>\n                <td align='left'><b>Order Total:</b></td>\n                <td align='left'>\n                  " . wpsc_cart_total() . "</td>\n            </tr>\n\t\t\t<tr>\n\t\t\t    <td align='left'><b>Shipping Address: </b></td>\n\t\t\t</tr>\n            <tr>\n                <td align='left'>\n                    Street 1:</td>\n                <td align='left'>" . $resArray['SHIPTOSTREET'] . "</td>\n\n            </tr>\n            <tr>\n                <td align='left'>\n                    Street 2:</td>\n                <td align='left'>" . $resArray['SHIPTOSTREET2'] . "\n                </td>\n            </tr>\n            <tr>\n                <td align='left'>\n                    City:</td>\n\n                <td align='left'>" . $resArray['SHIPTOCITY'] . "</td>\n            </tr>\n            <tr>\n                <td align='left'>\n                    State:</td>\n                <td align='left'>" . $resArray['SHIPTOSTATE'] . "</td>\n            </tr>\n            <tr>\n                <td align='left'>\n                    Postal code:</td>\n\n                <td align='left'>" . $resArray['SHIPTOZIP'] . "</td>\n            </tr>\n            <tr>\n                <td align='left'>\n                    Country:</td>\n                <td align='left'>" . $resArray['SHIPTOCOUNTRYNAME'] . "</td>\n            </tr>\n            <tr>\n                <td>";
                            $_SESSION['paypalExpressMessage'] .= "               \n                <input type='hidden' name='totalAmount' value='" . wpsc_cart_total(false) . "' />\n                <input type='hidden' name='shippingStreet' value='" . $resArray['SHIPTOSTREET'] . "' />          \n                <input type='hidden' name='shippingStreet2' value='" . $resArray['SHIPTOSTREET2'] . "' />\n                <input type='hidden' name='shippingCity' value='" . $resArray['SHIPTOCITY'] . "' />\n                <input type='hidden' name='shippingState' value='" . $resArray['SHIPTOSTATE'] . "' />\n                <input type='hidden' name='postalCode' value='" . $resArray['SHIPTOZIP'] . "' />\n                 <input type='hidden' name='country' value='" . $resArray['SHIPTOCOUNTRYNAME'] . "' />\n                <input type='hidden' name='token' value='" . $_SESSION['token'] . "' />\n\t\t\t\t\t<input type='hidden' name='PayerID' value='" . $_SESSION['payer_id'] . "' />\n\t\t\t\t\t<input type='hidden' name='act' value='do' />\n\t\t\t\t\t\n                   <p>  <label for='usePayPal'>Use PayPal Shipping Address: </label><input name='usePayPal' type='submit' value='Pay' /></p>\n                   <p>  <label for='useOther'>Use Previous Shipping Information:</label> <input name='useOther' type='submit' value='Pay' /></p>\n                </td>\n            </tr>\n        </table>\n    </center>\n    </form>";
                        }
                    }
                }
            }
        }
    }
}
開發者ID:papayalabs,項目名稱:htdocs,代碼行數:101,代碼來源:paypal_certified.php

示例13: submit

    function submit()
    {
        if (@extension_loaded('soap')) {
            $pxf = new PxFusion();
            # handles most of the Px Fusion magic
            // Work out the probable location of return.php since this sample
            // code could be anywhere on a development server.
            $returnUrl = add_query_arg('sessionid', $this->cart_data['session_id'], get_option('transact_url'));
            // Set some transaction details
            $pxf->set_txn_detail('txnType', 'Purchase');
            # required
            $pxf->set_txn_detail('currency', 'NZD');
            # required
            $pxf->set_txn_detail('returnUrl', $returnUrl);
            # required
            $pxf->set_txn_detail('amount', number_format(wpsc_cart_total(false), $decimals = 2, $dec_point = '.', $thousands_sep = ''));
            # required
            $pxf->set_txn_detail('merchantReference', get_bloginfo('name'));
            // Some of the many optional settings that could be specified:
            $pxf->set_txn_detail('enableAddBillCard', 0);
            $pxf->set_txn_detail('txnRef', substr(uniqid() . rand(1000, 9999), 0, 16));
            # random 16 digit reference);
            // Make the request for a transaction id
            $response = $pxf->get_transaction_id();
            if (!$response->GetTransactionIdResult->success) {
                wp_die('Error! There was a problem getting a transaction id from DPS, please contact the server administrator.');
            } else {
                // You should store these values in a database
                // ... they are needed to query the transaction's outcome
                $result = $response->GetTransactionIdResult;
                $transaction_id = $result->transactionId;
                $session_id = $result->sessionId;
            }
            $curlPost = array('SessionId' => $session_id, 'Add' => 'Add', 'CardHolderName' => $_POST['CardHolderName'], 'CardNumber' => $_POST['CardNumber'], 'Cvc2' => $_POST['Cvc2'], 'ExpiryMonth' => $_POST['ExpiryMonth'], 'ExpiryYear' => $_POST['ExpiryYear']);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, 'https://sec2.paymentexpress.com/pxmi3/pxfusionauth');
            curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
            curl_setopt($ch, CURLOPT_HEADER, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_CAINFO, WPSC_GOLD_FILE_PATH . "/merchants/paymentexpress/ThawteServerCA");
            $data = curl_exec($ch);
            curl_close($ch);
        } else {
            $data = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://paymentexpress.com">
						  <SOAP-ENV:Body>
						    <ns1:GetTransactionId>
						      <ns1:username>InstinctFusion</ns1:username>
						      <ns1:password>inst1234</ns1:password>
						      <ns1:tranDetail>
						        <ns1:amount>1.00</ns1:amount>
						        <ns1:currency>NZD</ns1:currency>
						        <ns1:enableAddBillCard>false</ns1:enableAddBillCard>
						        <ns1:merchantReference>Px Fusion -PHP</ns1:merchantReference>
						        <ns1:returnUrl>http://www.myReturnURL/return.php</ns1:returnUrl>
						        <ns1:txnRef>4cf703e6c79ff738</ns1:txnRef>
						        <ns1:txnType>Purchase</ns1:txnType>
						      </ns1:tranDetail>
						    </ns1:GetTransactionId>
						  </SOAP-ENV:Body>
						</SOAP-ENV:Envelope>';
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "https://sec2.paymentexpress.com/pxf/pxf.svc?wsdl");
            curl_setopt($ch, CURLOPT_VERBOSE, 0);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_POST, 1);
            // SSL security
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_CAINFO, WPSC_GOLD_FILE_PATH . "/merchants/paymentexpress/ThawteServerCA");
            //
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: \"http://paymentexpress.com/IPxFusion/GetTransactionId\"", "Content-length: " . strlen($data)));
            $response = curl_exec($ch);
            if (curl_errno($ch)) {
                wp_die('Curl error: ' . curl_error($ch) . '. Please contact server administrator.');
            }
            curl_close($ch);
            $xml_parser = xml_parser_create();
            if (!xml_parse_into_struct($xml_parser, $response, $vals, $index)) {
                wp_die("Error while parsing response from PX Fusion. Line " . xml_get_current_line_number($xml_parser) . '. Please contact server administrator.');
            }
            xml_parser_free($xml_parser);
            $parsed_xml = array();
            foreach ($vals as $val) {
                $parsed_xml[$val['tag']] = $val['value'];
            }
            if (!$parsed_xml['A:SUCCESS']) {
                wp_die('Error! There was a problem getting a transaction id from DPS, please contact the server administrator.');
            } else {
                // You should store these values in a database
                // ... they are needed to query the transaction's outcome
                $transaction_id = $parsed_xml["A:TRANSACTIONID"];
                $session_id = $parsed_xml["A:SESSIONID"];
            }
            $curlPost = array('SessionId' => $session_id, 'Add' => 'Add', 'CardHolderName' => $_POST['CardHolderName'], 'CardNumber' => $_POST['CardNumber'], 'Cvc2' => $_POST['Cvc2'], 'ExpiryMonth' => $_POST['ExpiryMonth'], 'ExpiryYear' => $_POST['ExpiryYear']);
//.........這裏部分代碼省略.........
開發者ID:hornet9,項目名稱:Morato,代碼行數:101,代碼來源:paymentexpress.php

示例14: compare_logic


//.........這裏部分代碼省略.........
                     if ($product_obj->quantity > $c['value']) {
                         return true;
                     }
                     break;
                 case 'less':
                     //Checks if the quantity of a product is less than the condition value
                     if ($product_obj->quantity < $c['value']) {
                         return true;
                     }
                     break;
                 case 'contains':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'not_contain':
                     //Checks if the product name contains the condition value
                     preg_match("/(.*)" . $c['value'] . "(.*)/", $product_obj->quantity, $match);
                     if (empty($match)) {
                         return true;
                     }
                     break;
                 case 'begins':
                     //Checks if the product name begins with condition value
                     preg_match("/^" . $c['value'] . "/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 case 'ends':
                     //Checks if the product name ends with condition value
                     preg_match("/" . $c['value'] . "\$/", $product_obj->quantity, $match);
                     if (!empty($match)) {
                         return true;
                     }
                     break;
                 default:
                     return false;
             }
         } else {
             if ($c['property'] == 'total_quantity') {
                 $total_quantity = wpsc_cart_item_count();
                 switch ($c['logic']) {
                     case 'equal':
                         //Checks if the quantity of products in the cart equals condition value
                         if ($total_quantity == $c['value']) {
                             return true;
                         }
                         break;
                     case 'greater':
                         //Checks if the quantity in the cart is greater than the condition value
                         if ($total_quantity > $c['value']) {
                             return true;
                         }
                         break;
                     case 'less':
                         //Checks if the quantity in the cart is less than the condition value
                         if ($total_quantity < $c['value']) {
                             return true;
                         }
                         break;
                     default:
                         return false;
                 }
             } else {
                 if ($c['property'] == 'subtotal_amount') {
                     $subtotal = wpsc_cart_total(false);
                     switch ($c['logic']) {
                         case 'equal':
                             //Checks if the subtotal of products in the cart equals condition value
                             if ($subtotal == $c['value']) {
                                 return true;
                             }
                             break;
                         case 'greater':
                             //Checks if the subtotal of the cart is greater than the condition value
                             if ($subtotal > $c['value']) {
                                 return true;
                             }
                             break;
                         case 'less':
                             //Checks if the subtotal of the cart is less than the condition value
                             if ($subtotal < $c['value']) {
                                 return true;
                             } else {
                                 return false;
                             }
                             break;
                         default:
                             return false;
                     }
                 } else {
                     return apply_filters('wpsc_coupon_compare_logic', false, $c, $product_obj);
                 }
             }
         }
     }
 }
開發者ID:nikitanaumov,項目名稱:WP-e-Commerce,代碼行數:101,代碼來源:coupons.class.php

示例15: paypal_processingfunctions


//.........這裏部分代碼省略.........
                    			the varialbes were set in the web form, and the resulting string
                    			is stored in $nvpstr */
                    $nvpstr = "&Amt=" . $paymentAmount . "&PAYMENTACTION=" . $paymentType . "&ReturnUrl=" . $returnURL . "&CANCELURL=" . $cancelURL . "&CURRENCYCODE=" . $currencyCodeType;
                    /* Make the call to PayPal to set the Express Checkout token
                    			If the API call succeded, then redirect the buyer to PayPal
                    			to begin to authorize payment.  If an error occured, show the
                    			resulting errors
                    			*/
                    $resArray = paypal_hash_call("SetExpressCheckout", $nvpstr);
                    $_SESSION['reshash'] = $resArray;
                    $ack = strtoupper($resArray["ACK"]);
                    if ($ack == "SUCCESS") {
                        // Redirect to paypal.com here
                        $token = urldecode($resArray["TOKEN"]);
                        $payPalURL = $PAYPAL_URL . $token;
                        wp_redirect($payPalURL);
                    } else {
                        // Redirecting to APIError.php to display errors.
                        $location = get_option('transact_url') . "&act=error";
                        wp_redirect($location);
                    }
                    exit;
                } else {
                    /* At this point, the buyer has completed in authorizing payment
                    			at PayPal.  The script will now call PayPal with the details
                    			of the authorization, incuding any shipping information of the
                    			buyer.  Remember, the authorization is not a completed transaction
                    			at this state - the buyer still needs an additional step to finalize
                    			the transaction
                    			*/
                    $token = urlencode($_REQUEST['token']);
                    /* Build a second API request to PayPal, using the token as the
                    			ID to get the details on the payment authorization
                    			*/
                    $nvpstr = "&TOKEN=" . $token;
                    /* Make the API call and store the results in an array.  If the
                    			call was a success, show the authorization details, and provide
                    			an action to complete the payment.  If failed, show the error
                    			*/
                    $resArray = paypal_hash_call("GetExpressCheckoutDetails", $nvpstr);
                    $_SESSION['reshash'] = $resArray;
                    $ack = strtoupper($resArray["ACK"]);
                    if ($ack == "SUCCESS") {
                        /********************************************************
                        			GetExpressCheckoutDetails.php
                        			
                        			This functionality is called after the buyer returns from
                        			PayPal and has authorized the payment.
                        			
                        			Displays the payer details returned by the
                        			GetExpressCheckoutDetails response and calls
                        			DoExpressCheckoutPayment.php to complete the payment
                        			authorization.
                        			
                        			Called by ReviewOrder.php.
                        			
                        			Calls DoExpressCheckoutPayment.php and APIError.php.
                        			
                        			********************************************************/
                        session_start();
                        /* Collect the necessary information to complete the
                        			authorization for the PayPal payment
                        			*/
                        $_SESSION['token'] = $_REQUEST['token'];
                        $_SESSION['payer_id'] = $_REQUEST['PayerID'];
                        $resArray = $_SESSION['reshash'];
                        if (get_option('permalink_structure') != '') {
                            $separator = "?";
                        } else {
                            $separator = "&";
                        }
                        /* Display the  API response back to the browser .
                        			If the response from PayPal was a success, display the response parameters
                        			*/
                        if (isset($_REQUEST['TOKEN']) && !isset($_REQUEST['PAYERID'])) {
                            $_SESSION['paypalExpressMessage'] = '<h4>TRANSACTION CANCELED</h4>';
                        } else {
                            $output = "\n\t\t\t\t       <table width='400' class='paypal_express_form'>\n\t\t\t\t        <tr>\n\t\t\t\t            <td align='left' class='firstcol'><b>" . __('Error Number:', 'wpsc') . "Order Total:</b></td>\n\t\t\t\t            <td align='left'>" . wpsc_currency_display($_SESSION['paypalAmount']) . "</td>\n\t\t\t\t        </tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t    <td align='left'><b>" . __('Shipping Address:', 'wpsc') . " </b></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t        <tr>\n\t\t\t\t            <td align='left' class='firstcol'>\n\t\t\t\t                " . __('Street 1:', 'wpsc') . "</td>\n\t\t\t\t            <td align='left'>" . $resArray['SHIPTOSTREET'] . "</td>\n\t\t\t\t\n\t\t\t\t        </tr>\n\t\t\t\t        <tr>\n\t\t\t\t            <td align='left' class='firstcol'>\n\t\t\t\t                " . __('Street 2:', 'wpsc') . "</td>\n\t\t\t\t            <td align='left'>" . $resArray['SHIPTOSTREET2'] . "\n\t\t\t\t            </td>\n\t\t\t\t        </tr>\n\t\t\t\t        <tr>\n\t\t\t\t            <td align='left' class='firstcol'>\n\t\t\t\t                " . __('City:', 'wpsc') . "</td>\n\t\t\t\t\n\t\t\t\t            <td align='left'>" . $resArray['SHIPTOCITY'] . "</td>\n\t\t\t\t        </tr>\n\t\t\t\t        <tr>\n\t\t\t\t            <td align='left' class='firstcol'>\n\t\t\t\t                " . __('State:', 'wpsc') . "</td>\n\t\t\t\t            <td align='left'>" . $resArray['SHIPTOSTATE'] . "</td>\n\t\t\t\t        </tr>\n\t\t\t\t        <tr>\n\t\t\t\t            <td align='left' class='firstcol'>\n\t\t\t\t                " . __('Postal code:', 'wpsc') . "</td>\n\t\t\t\t\n\t\t\t\t            <td align='left'>" . $resArray['SHIPTOZIP'] . "</td>\n\t\t\t\t        </tr>\n\t\t\t\t        <tr>\n\t\t\t\t            <td align='left' class='firstcol'>\n\t\t\t\t                " . __('Country:', 'wpsc') . "</td>\n\t\t\t\t            <td align='left'>" . $resArray['SHIPTOCOUNTRYNAME'] . "</td>\n\t\t\t\t        </tr>\n\t\t\t\t        <tr>\n\t\t\t\t            <td>";
                            $output .= "<form action=" . get_option('transact_url') . " method='post'>\n";
                            $output .= "\t<input type='hidden' name='totalAmount' value='" . wpsc_cart_total(false) . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingStreet' value='" . $resArray['SHIPTOSTREET'] . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingStreet2' value='" . $resArray['SHIPTOSTREET2'] . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingCity' value='" . $resArray['SHIPTOCITY'] . "' />\n";
                            $output .= "\t<input type='hidden' name='shippingState' value='" . $resArray['SHIPTOSTATE'] . "' />\n";
                            $output .= "\t<input type='hidden' name='postalCode' value='" . $resArray['SHIPTOZIP'] . "' />\n";
                            $output .= "\t<input type='hidden' name='country' value='" . $resArray['SHIPTOCOUNTRYNAME'] . "' />\n";
                            $output .= "\t<input type='hidden' name='token' value='" . $_SESSION['token'] . "' />\n";
                            $output .= "\t<input type='hidden' name='PayerID' value='" . $_SESSION['payer_id'] . "' />\n";
                            $output .= "\t<input type='hidden' name='act' value='do' />\n";
                            $output .= "\t<p>  <input name='usePayPal' type='submit' value='" . __('Confirm Payment', 'wpsc') . "' /></p>\n";
                            $output .= "</form>";
                            $output .= " </td>\n\t\t\t\t\t        </tr>\n\t\t\t\t\t    </table>\n\t\t\t\t\t</center>\n\t\t\t\t\t";
                            $_SESSION['paypalExpressMessage'] = $output;
                        }
                    }
                }
            }
        }
    }
}
開發者ID:hornet9,項目名稱:Morato,代碼行數:101,代碼來源:paypal-express.merchant.php


注:本文中的wpsc_cart_total函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。