/**
 * WP eCommerce Admin AJAX functions
 *
 * These are the WPSC Admin AJAX functions
 *
 * @package wp-e-commerce
 * @since 3.7
 *
 * @uses update_option()                              Updates option in the database given key and value
 * @uses wp_delete_term()                             Removes term from the database
 * @uses fetch_rss()                                  DEPRECATED
 * @uses wpsc_member_dedeactivate_subscriptions()     @todo docs
 * @uses wpsc_member_deactivate_subscriptions()       @todo docs
 * @uses wpsc_update_purchase_log_status()            Updates the status of the logs for a purchase
 * @uses transaction_results()                        Main function for creating purchase reports
 * @uses wpsc_find_purchlog_status_name()             Finds name of given status
 */
function wpsc_admin_ajax()
{
    if (!wpsc_is_store_admin()) {
        return;
    }
    global $wpdb;
    if (isset($_POST['action']) && $_POST['action'] == 'product-page-order') {
        $current_order = get_option('wpsc_product_page_order');
        $new_order = $_POST['order'];
        if (isset($new_order["advanced"])) {
            $current_order["advanced"] = array_unique(explode(',', $new_order["advanced"]));
        }
        if (isset($new_order["side"])) {
            $current_order["side"] = array_unique(explode(',', $new_order["side"]));
        }
        update_option('wpsc_product_page_order', $current_order);
        exit(print_r($order, 1));
    }
    if (isset($_POST['save_image_upload_state']) && $_POST['save_image_upload_state'] == 'true' && is_numeric($_POST['image_upload_state'])) {
        $upload_state = (int) (bool) $_POST['image_upload_state'];
        update_option('wpsc_use_flash_uploader', $upload_state);
        exit("done");
    }
    if (isset($_POST['remove_variation_value']) && $_POST['remove_variation_value'] == "true" && is_numeric($_POST['variation_value_id'])) {
        $value_id = absint($_GET['variation_value_id']);
        echo wp_delete_term($value_id, 'wpsc-variation');
        exit;
    }
    if (isset($_REQUEST['log_state']) && $_REQUEST['log_state'] == "true" && is_numeric($_POST['id']) && is_numeric($_POST['value'])) {
        $newvalue = $_POST['value'];
        if ($_REQUEST['suspend'] == 'true') {
            if ($_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions')) {
                wpsc_member_dedeactivate_subscriptions($_POST['id']);
            } elseif (function_exists('wpsc_member_deactivate_subscriptions')) {
                wpsc_member_deactivate_subscriptions($_POST['id']);
            }
            exit;
        } else {
            $log_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id']), ARRAY_A);
            if ($newvalue == 2 && function_exists('wpsc_member_activate_subscriptions')) {
                wpsc_member_activate_subscriptions($_POST['id']);
            }
            wpsc_update_purchase_log_status($_POST['id'], $newvalue);
            if ($newvalue > $log_data['processed'] && $log_data['processed'] < 2) {
                transaction_results($log_data['sessionid'], false);
            }
            $status_name = wpsc_find_purchlog_status_name($purchase['processed']);
            echo "document.getElementById(\"form_group_" . absint($_POST['id']) . "_text\").innerHTML = '" . $status_name . "';\n";
            $year = date("Y");
            $month = date("m");
            $start_timestamp = mktime(0, 0, 0, $month, 1, $year);
            $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year);
            echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price($start_timestamp, $end_timestamp))) . "';\n";
            echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price())) . "';\n";
            exit;
        }
    }
}
예제 #2
0
/**
 * 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);
}
예제 #3
0
파일: cart.php 프로젝트: ashik968/digiplot
/**
 * Cart Total Widget
 *
 * Can be used to display the cart total excluding shipping, tax or coupons.
 *
 * @since 3.7.6.2
 *
 * @return string The subtotal price of the cart, with a currency sign.
 */
function wpsc_cart_total_widget($shipping = true, $tax = true, $coupons = true)
{
    global $wpsc_cart;
    $total = $wpsc_cart->calculate_subtotal();
    if ($shipping) {
        $total += $wpsc_cart->calculate_total_shipping();
    }
    if ($tax && wpsc_tax_isincluded() == false) {
        $total += $wpsc_cart->calculate_total_tax();
    }
    if ($coupons) {
        $total -= $wpsc_cart->coupons_amount;
    }
    if (get_option('add_plustax') == 1) {
        return wpsc_currency_display($wpsc_cart->calculate_subtotal());
    } else {
        return wpsc_currency_display($total);
    }
}
예제 #4
0
/**
 * WPSC Product Variation Price From
 * Gets the formatted lowest price of a product's variations.
 *
 * @since  3.8.10
 *
 * @param  $product_id  (int)       Product ID
 * @param  $args        (array)     Array of options
 * @return              (string)    Number formatted price
 *
 * @uses   apply_filters()          Calls 'wpsc_do_convert_price' passing price and product ID.
 * @uses   wpsc_currency_display()  Passing price and args.
 */
function wpsc_product_variation_price_from($product_id, $args = null)
{
    global $wpdb;
    $args = wp_parse_args($args, array('from_text' => false, 'only_normal_price' => false, 'only_in_stock' => false));
    static $price_data = array();
    /* @todo: Rewrite using proper WP_Query */
    if (isset($price_data[$product_id])) {
        $results = $price_data[$product_id];
    } else {
        $stock_sql = '';
        if ($args['only_in_stock']) {
            $stock_sql = "INNER JOIN {$wpdb->postmeta} AS pm3 ON pm3.post_id = p.id AND pm3.meta_key = '_wpsc_stock' AND pm3.meta_value != '0'";
        }
        $sql = $wpdb->prepare("\n\t\t\tSELECT pm.meta_value AS price, pm2.meta_value AS special_price\n\t\t\tFROM {$wpdb->posts} AS p\n\t\t\tINNER JOIN {$wpdb->postmeta} AS pm ON pm.post_id = p.id AND pm.meta_key = '_wpsc_price'\n\t\t\tLEFT JOIN {$wpdb->postmeta} AS pm2 ON pm2.post_id = p.id AND pm2.meta_key = '_wpsc_special_price'\n\t\t\t{$stock_sql}\n\t\t\tWHERE p.post_type = 'wpsc-product' AND p.post_parent = %d AND p.post_status IN ( 'publish', 'inherit' )\n\t\t", $product_id);
        $results = $wpdb->get_results($sql);
        $price_data[$product_id] = $results;
    }
    $prices = array();
    foreach ($results as $row) {
        $price = (double) $row->price;
        if (!$args['only_normal_price']) {
            $special_price = (double) $row->special_price;
            if ($special_price != 0 && $special_price < $price) {
                $price = $special_price;
            }
        }
        $prices[] = $price;
    }
    sort($prices);
    if (empty($prices)) {
        $prices[] = 0;
    }
    $price = apply_filters('wpsc_do_convert_price', $prices[0], $product_id);
    $price = wpsc_currency_display($price, array('display_as_html' => false));
    if (isset($prices[0]) && $prices[0] == $prices[count($prices) - 1]) {
        $args['from_text'] = false;
    }
    if ($args['from_text']) {
        $price = sprintf($args['from_text'], $price);
    }
    return $price;
}
 private function get_table_args()
 {
     $log_id = $this->purchase_log->get('id');
     $log_data = $this->purchase_log->get_data();
     $rows = array();
     $headings = array(_x('Name', 'purchase log notification table heading', 'wp-e-commerce') => 'left', _x('Price', 'purchase log notification table heading', 'wp-e-commerce') => 'right', _x('Quantity', 'purchase log notification table heading', 'wp-e-commerce') => 'right', _x('Item Total', 'purchase log notification table heading', 'wp-e-commerce') => 'right');
     $has_additional_details = false;
     $additional_details = array();
     foreach ($this->purchase_log->get_cart_contents() as $item) {
         $cart_item_array = array('purchase_id' => $log_id, 'cart_item' => (array) $item, 'purchase_log' => $log_data);
         // legacy code, which Gary honestly doesn't fully understand because it just doesn't make sense
         // prior to 3.8.9, these actions are called on each product item. Don't really know what they do.
         do_action('wpsc_transaction_result_cart_item', $cart_item_array);
         do_action('wpsc_confirm_checkout', $log_id);
         // then there's also this annoying apply_filters call, which is apparently not the best example
         // of how to use it, but we have to preserve them anyways
         $additional_content = apply_filters('wpsc_transaction_result_content', $cart_item_array);
         if (!is_string($additional_content)) {
             $additional_content = '';
         } else {
             $has_additional_details = true;
         }
         $additional_details[] = $additional_content;
         $item_total = $item->quantity * $item->price;
         $item_total = wpsc_currency_display($item_total, array('display_as_html' => false));
         $item_price = wpsc_currency_display($item->price, array('display_as_html' => false));
         $item_name = apply_filters('the_title', $item->name);
         $rows[] = array($item_name, $item_price, $item->quantity, $item_total);
     }
     // Preserve the 'wpsc_transaction_result_content' filter for backward compat
     if ($has_additional_details) {
         $headings[] = __('Additional Details', 'wp-e-commerce');
         foreach ($rows as $index => $row) {
             $rows[] = $additional_details[$index];
         }
     }
     $table_args = array('headings' => $headings, 'rows' => $rows);
     return apply_filters('wpsc_purchase_log_notification_product_table_args', $table_args, $this);
 }
/**
 * prcessing functions, this is where the main logic of paypal express lives
 * @access public
 *
 * @since 3.8
 */
function paypal_processingfunctions()
{
    global $wpdb, $wpsc_cart;
    $sessionid = (string) wpsc_get_customer_meta('paypal_express_sessionid');
    if (isset($_REQUEST['act']) && 'error' == $_REQUEST['act']) {
        $resArray = wpsc_get_customer_meta('paypal_express_reshash');
        $paypal_express_message = '
		<center>
		<table width="700" align="left">
		<tr>
			<td colspan="2" class="header">' . __('The PayPal API has returned an error!', 'wpsc') . '</td>
		</tr>
		';
        //it will print if any URL errors
        if (wpsc_get_customer_meta('paypal_express_curl_error_msg')) {
            $errorMessage = wpsc_get_customer_meta('paypal_express_curl_error_msg');
            $response = wpsc_get_customer_meta('paypal_express_response');
            $paypal_express_message .= '
			<tr>
				<td>response:</td>
				<td>' . $response . '</td>
			</tr>

			<tr>
				<td>Error Message:</td>
				<td>' . $errorMessage . '</td>
			</tr>';
        } else {
            /* If there is no URL Errors, Construct the HTML page with
               Response Error parameters.   */
            $paypal_express_message .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Ack:</td>\n\t\t\t\t\t<td>" . $resArray['ACK'] . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Correlation ID:</td>\n\t\t\t\t\t<td>" . $resArray['CORRELATIONID'] . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Version:</td>\n\t\t\t\t\t<td>" . $resArray['VERSION'] . "</td>\n\t\t\t\t</tr>";
            $count = 0;
            while (isset($resArray["L_SHORTMESSAGE" . $count])) {
                $errorCode = $resArray["L_ERRORCODE" . $count];
                $shortMessage = $resArray["L_SHORTMESSAGE" . $count];
                $longMessage = $resArray["L_LONGMESSAGE" . $count];
                $count = $count + 1;
                $paypal_express_message .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . __('Error Number:', 'wpsc') . "</td>\n\t\t\t\t\t\t<td> {$errorCode} </td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . __('Short Message:', 'wpsc') . "</td>\n\t\t\t\t\t\t<td> {$shortMessage} </td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . __('Long Message:', 'wpsc') . "</td>\n\t\t\t\t\t\t<td> {$longMessage} </td>\n\t\t\t\t\t</tr>";
            }
            //end while
        }
        // end else
        $paypal_express_message .= "\n\t\t\t</center>\n\t\t\t\t</table>";
        wpsc_update_customer_meta('paypal_express_message', $paypal_express_message);
    } else {
        if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'do') {
            /* Gather the information to make the final call to
               finalize the PayPal payment.  The variable nvpstr
               holds the name value pairs   */
            $token = urlencode($_REQUEST['token']);
            $paymentAmount = urlencode(wpsc_get_customer_meta('paypal_express_converted_amount'));
            $paymentType = urlencode(wpsc_get_customer_meta('paypal_express_payment_type'));
            $currCodeType = urlencode(wpsc_get_paypal_currency_code());
            $payerID = urlencode($_REQUEST['PayerID']);
            $serverName = urlencode($_SERVER['SERVER_NAME']);
            $BN = 'Instinct_e-commerce_wp-shopping-cart_NZ';
            $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=Sale&PAYMENTREQUEST_0_CURRENCYCODE=' . $currCodeType . '&IPADDRESS=' . $serverName . "&BUTTONSOURCE=" . $BN . "&PAYMENTREQUEST_0_INVNUM=" . urlencode($sessionid);
            // IPN data
            if (get_option('paypal_ipn') == 1) {
                $notify_url = add_query_arg('wpsc_action', 'gateway_notification', get_option('siteurl') . "/index.php");
                $notify_url = add_query_arg('gateway', 'wpsc_merchant_paypal_express', $notify_url);
                $notify_url = apply_filters('wpsc_paypal_express_notify_url', $notify_url);
                $nvpstr .= '&PAYMENTREQUEST_0_NOTIFYURL=' . urlencode($notify_url);
            }
            // Horrible code that I had to write to hot fix the issue with missing item detail in email receipts. arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrgh!!!!! @#@$%@#%@##$#$
            $purchase_log = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = %s", $sessionid), ARRAY_A);
            $cart_data = $original_cart_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = {$purchase_log['id']}", ARRAY_A);
            $i = 0;
            $item_total = 0;
            $shipping_total = 0;
            foreach ($cart_data as $cart_item) {
                $converted_price = wpsc_paypal_express_convert($cart_item['price']);
                $nvpstr .= "&L_PAYMENTREQUEST_0_NAME{$i}=" . urlencode(apply_filters('the_title', $cart_item['name']));
                $nvpstr .= "&L_PAYMENTREQUEST_0_AMT{$i}=" . $converted_price;
                $nvpstr .= "&L_PAYMENTREQUEST_0_NUMBER{$i}=" . $i;
                $nvpstr .= "&L_PAYMENTREQUEST_0_QTY{$i}=" . $cart_item['quantity'];
                $item_total += $converted_price * $cart_item['quantity'];
                $shipping_total += wpsc_paypal_express_convert($cart_item['pnp']);
                $i++;
            }
            //if we have a discount then include a negative amount with that discount
            if ($purchase_log['discount_value'] && 0.0 != $purchase_log['discount_value']) {
                $discount_value = wpsc_paypal_express_convert($purchase_log['discount_value']);
                // if item total < discount amount, leave at least 0.01 unit in item total, then subtract
                // 0.01 from shipping as well
                if ($discount_value >= $item_total) {
                    $discount_value = $item_total - 0.01;
                    $shipping_total -= 0.01;
                }
                $nvpstr .= "&L_PAYMENTREQUEST_0_NAME{$i}=" . urlencode("Discount / Coupon");
                $nvpstr .= "&L_PAYMENTREQUEST_0_AMT{$i}=-" . urlencode($discount_value);
                $nvpstr .= "&L_PAYMENTREQUEST_0_NUMBER{$i}={$i}";
                $nvpstr .= "&L_PAYMENTREQUEST_0_QTY{$i}=1";
                $item_total -= $discount_value;
            }
            $item_total = wpsc_paypal_express_format($item_total);
            $shipping_total = wpsc_paypal_express_convert($purchase_log['base_shipping']) + $shipping_total;
            $nvpstr .= '&PAYMENTREQUEST_0_ITEMAMT=' . $item_total;
            $nvpstr .= '&PAYMENTREQUEST_0_SHIPPINGAMT=' . $shipping_total;
            $total = $item_total + $shipping_total;
            if (!wpsc_tax_isincluded()) {
                $tax = wpsc_paypal_express_convert($purchase_log['wpec_taxes_total']);
                $nvpstr .= '&PAYMENTREQUEST_0_TAXAMT=' . $tax;
                $total += $tax;
            }
            // adjust total amount in case we had to round up after converting currency
            if ($total != $paymentAmount) {
                $paymentAmount = $total;
            }
            $nvpstr .= "&PAYMENTREQUEST_0_AMT={$paymentAmount}";
            $resArray = paypal_hash_call("DoExpressCheckoutPayment", $nvpstr);
            /* Display the API response back to the browser.
               If the response from PayPal was a success, display the response parameters'
               If the response was an error, display the errors received using APIError.php. */
            $ack = strtoupper($resArray["ACK"]);
            wpsc_update_customer_meta('paypal_express_reshash', $resArray);
            if ($ack != "SUCCESS") {
                $location = get_option('transact_url') . "&act=error";
            } else {
                $transaction_id = $resArray['PAYMENTINFO_0_TRANSACTIONID'];
                switch ($resArray['PAYMENTINFO_0_PAYMENTSTATUS']) {
                    case 'Processed':
                        // I think this is mostly equivalent to Completed
                    // I think this is mostly equivalent to Completed
                    case 'Completed':
                        wpsc_update_purchase_log_status($sessionid, 3, 'sessionid');
                        transaction_results($sessionid, false);
                        break;
                    case 'Pending':
                        // need to wait for "Completed" before processing
                        wpsc_update_purchase_log_details($sessionid, array('processed' => 2, 'date' => time(), 'transactid' => $transaction_id), 'sessionid');
                        break;
                }
                $location = add_query_arg('sessionid', $sessionid, get_option('transact_url'));
                wpsc_delete_customer_meta('paypal_express_message');
                wp_redirect($location);
                exit;
            }
            wpsc_delete_customer_meta('nzshpcrt_serialized_cart');
            wpsc_delete_customer_meta('nzshpcart');
            $wpsc_cart->empty_cart();
        } else {
            if (isset($_REQUEST['paymentType']) || isset($_REQUEST['token'])) {
                $token = $_REQUEST['token'];
                if (!isset($token)) {
                    $paymentAmount = wpsc_get_customer_meta('paypal_express_converted_amount');
                    $currencyCodeType = wpsc_get_paypal_currency_code();
                    $paymentType = 'Sale';
                    if (get_option('permalink_structure') != '') {
                        $separator = "?";
                    } else {
                        $separator = "&";
                    }
                    $returnURL = urlencode(get_option('transact_url') . $separator . 'currencyCodeType=' . $currencyCodeType . '&paymentType=' . $paymentType . '&paymentAmount=' . $paymentAmount);
                    $cancelURL = urlencode(get_option('transact_url') . $separator . '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 = "&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);
                        }
                    }
                }
            }
        }
    }
}
예제 #7
0
function wpsc_packing_slip($purchase_id)
{
    _wpsc_deprecated_function(__FUNCTION__, '3.8.13');
    echo "<!DOCTYPE html><html><meta http-equiv=\"content-type\" content=\"text-html; charset=utf-8\"><head><title>" . __('Packing Slip', 'wp-e-commerce') . "</title></head><body id='wpsc-packing-slip'>";
    global $wpdb;
    $purch_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`=%d", $purchase_id);
    $purch_data = $wpdb->get_row($purch_sql, ARRAY_A);
    $cartsql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=%d", $purchase_id);
    $cart_log = $wpdb->get_results($cartsql, ARRAY_A);
    $j = 0;
    if ($cart_log != null) {
        echo "<div class='packing_slip'>\n\r";
        echo apply_filters('wpsc_packing_slip_header', '<h2>' . esc_html__('Packing Slip', 'wp-e-commerce') . "</h2>\n\r");
        echo "<strong>" . esc_html__('Order', 'wp-e-commerce') . " #</strong> " . $purchase_id . "<br /><br />\n\r";
        echo "<table>\n\r";
        $form_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d", $purchase_id);
        $input_data = $wpdb->get_results($form_sql, ARRAY_A);
        foreach ($input_data as $input_row) {
            $rekeyed_input[$input_row['form_id']] = $input_row;
        }
        if ($input_data != null) {
            $form_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' ORDER BY `checkout_order`", ARRAY_A);
            foreach ($form_data as $form_field) {
                switch ($form_field['type']) {
                    case 'country':
                        $region_count_sql = $wpdb->prepare("SELECT COUNT(`regions`.`id`) FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('%s')", $purch_data['billing_country']);
                        $delivery_region_count = $wpdb->get_var($region_count_sql);
                        if (is_numeric($purch_data['billing_region']) && $delivery_region_count > 0) {
                            echo "\t<tr><td>" . esc_html__('State', 'wp-e-commerce') . ":</td><td>" . wpsc_get_region($purch_data['billing_region']) . "</td></tr>\n\r";
                        }
                        echo "\t<tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($rekeyed_input[$form_field['id']]['value']) . "</td></tr>\n\r";
                        break;
                    case 'delivery_country':
                        if (is_numeric($purch_data['shipping_region']) && $delivery_region_count > 0) {
                            echo "\t<tr><td>" . esc_html__('State', 'wp-e-commerce') . ":</td><td>" . wpsc_get_region($purch_data['shipping_region']) . "</td></tr>\n\r";
                        }
                        echo "\t<tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($rekeyed_input[$form_field['id']]['value']) . "</td></tr>\n\r";
                        break;
                    case 'heading':
                        if ($form_field['name'] == "Hidden Fields") {
                            continue;
                        } else {
                            echo "\t<tr class='heading'><td colspan='2'><strong>" . esc_html($form_field['name']) . ":</strong></td></tr>\n\r";
                        }
                        break;
                    default:
                        if ($form_field['name'] == "State" && !empty($purch_data['billing_region']) || $form_field['name'] == "State" && !empty($purch_data['billing_region'])) {
                            echo "";
                        } else {
                            echo "\t<tr><td>" . esc_html($form_field['name']) . ":</td><td>" . (isset($rekeyed_input[$form_field['id']]) ? esc_html($rekeyed_input[$form_field['id']]['value']) : '') . "</td></tr>\n\r";
                        }
                        break;
                }
            }
        } else {
            echo "\t<tr><td>" . esc_html__('Name', 'wp-e-commerce') . ":</td><td>" . $purch_data['firstname'] . " " . $purch_data['lastname'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . esc_html__('Address', 'wp-e-commerce') . ":</td><td>" . $purch_data['address'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . esc_html__('Phone', 'wp-e-commerce') . ":</td><td>" . $purch_data['phone'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . esc_html__('Email', 'wp-e-commerce') . ":</td><td>" . $purch_data['email'] . "</td></tr>\n\r";
        }
        if (2 == get_option('payment_method')) {
            $gateway_name = '';
            global $nzshpcrt_gateways;
            foreach ($nzshpcrt_gateways as $gateway) {
                if ($purch_data['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purch_data['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = esc_html__('Manual Payment', 'wp-e-commerce');
                }
            }
        }
        echo "</table>\n\r";
        do_action('wpsc_packing_slip_extra_info', $purchase_id);
        echo "<table class='packing_slip'>";
        echo "<tr>";
        echo " <th>" . esc_html__('Quantity', 'wp-e-commerce') . " </th>";
        echo " <th>" . esc_html__('Name', 'wp-e-commerce') . "</th>";
        echo " <th>" . esc_html__('Price', 'wp-e-commerce') . " </th>";
        echo " <th>" . esc_html__('Shipping', 'wp-e-commerce') . " </th>";
        echo '<th>' . esc_html__('Tax', 'wp-e-commerce') . '</th>';
        echo '</tr>';
        $endtotal = 0;
        $all_donations = true;
        $all_no_shipping = true;
        $file_link_list = array();
        $total_shipping = 0;
        foreach ($cart_log as $cart_row) {
            $alternate = "";
            $j++;
            if ($j % 2 != 0) {
                $alternate = "class='alt'";
            }
            // product ID will be $cart_row['prodid']. need to fetch name and stuff
            $variation_list = '';
            if ($cart_row['donation'] != 1) {
                $all_donations = false;
            }
            if ($cart_row['no_shipping'] != 1) {
                $shipping = $cart_row['pnp'];
                $total_shipping += $shipping;
                $all_no_shipping = false;
            } else {
                $shipping = 0;
            }
            $price = $cart_row['price'] * $cart_row['quantity'];
            $gst = $price - $price / (1 + $cart_row['gst'] / 100);
            if ($gst > 0) {
                $tax_per_item = $gst / $cart_row['quantity'];
            }
            echo "<tr {$alternate}>";
            echo " <td>";
            echo $cart_row['quantity'];
            echo " </td>";
            echo " <td>";
            echo apply_filters('the_title', $cart_row['name']);
            echo $variation_list;
            echo " </td>";
            echo " <td>";
            echo wpsc_currency_display($price);
            echo " </td>";
            echo " <td>";
            echo wpsc_currency_display($shipping);
            echo " </td>";
            echo '<td>';
            echo wpsc_currency_display($cart_row['tax_charged']);
            echo '</td>';
            echo '</tr>';
        }
        echo "</table>";
        echo '<table class="packing-slip-totals">';
        if (floatval($purch_data['discount_value'])) {
            echo '<tr><th>' . esc_html__('Discount', 'wp-e-commerce') . '</th><td>(' . wpsc_currency_display($purch_data['discount_value']) . ')</td></tr>';
        }
        echo '<tr><th>' . esc_html__('Base Shipping', 'wp-e-commerce') . '</th><td>' . wpsc_currency_display($purch_data['base_shipping']) . '</td></tr>';
        echo '<tr><th>' . esc_html__('Total Shipping', 'wp-e-commerce') . '</th><td>' . wpsc_currency_display($purch_data['base_shipping'] + $total_shipping) . '</td></tr>';
        //wpec_taxes
        if ($purch_data['wpec_taxes_total'] != 0.0) {
            echo '<tr><th>' . esc_html__('Taxes', 'wp-e-commerce') . '</th><td>' . wpsc_currency_display($purch_data['wpec_taxes_total']) . '</td></tr>';
        }
        echo '<tr><th>' . esc_html__('Total Price', 'wp-e-commerce') . '</th><td>' . wpsc_currency_display($purch_data['totalprice']) . '</td></tr>';
        echo '</table>';
        echo "</div>\n\r";
    } else {
        echo "<br />" . esc_html__('This users cart was empty', 'wp-e-commerce');
    }
}
예제 #8
0
function wpsc_display_purchlog_details()
{
    while (wpsc_have_purchaselog_details()) {
        wpsc_the_purchaselog_item();
        ?>
   <tr>
      <td><?php 
        echo wpsc_purchaselog_details_name();
        ?>
</td> <!-- NAME! -->
      <td><?php 
        echo wpsc_purchaselog_details_SKU();
        ?>
</td> <!-- SKU! -->
      <td><?php 
        echo wpsc_purchaselog_details_quantity();
        ?>
</td> <!-- QUANTITY! -->
      <td><?php 
        echo wpsc_currency_display(wpsc_purchaselog_details_price());
        ?>
</td> <!-- PRICE! -->
      <td><?php 
        echo wpsc_currency_display(wpsc_purchaselog_details_shipping());
        ?>
</td> <!-- SHIPPING! -->
      <td><?php 
        if (wpec_display_product_tax()) {
            echo wpsc_currency_display(wpsc_purchaselog_details_tax());
        }
        ?>
</td> <!-- TAX! -->
      <!-- <td><?php 
        echo wpsc_currency_display(wpsc_purchaselog_details_discount());
        ?>
</td> --> <!-- DISCOUNT! -->
      <td><?php 
        echo wpsc_currency_display(wpsc_purchaselog_details_total());
        ?>
</td> <!-- TOTAL! -->
   </tr>
<?php 
    }
}
예제 #9
0
/**
 * 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']) {
                    $selected = "selected='selected'";
                } else {
                    $selected = "";
                }
                $output .= "   <option value='" . $region['id'] . "' {$selected}>" . htmlspecialchars($region['name']) . "</option>\n\r";
            }
            $output .= "</select>\n\r";
            $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output));
            echo "jQuery('#region_select_{$form_id}').html(\"" . $output . "\");\n\r";
            echo "\n\t\t\t\tvar wpsc_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpsc_checkout_table').attr('class');\n\t\t\t\twpsc_checkout_table_selector = wpsc_checkout_table_selector.replace(' ','.');\n\t\t\t\twpsc_checkout_table_selector = '.'+wpsc_checkout_table_selector;\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.billing_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.shipping_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .billing_region').parent().parent().hide();\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .shipping_region').parent().parent().hide();\n\t\t\t";
        } else {
            if (get_option('lock_tax') == 1) {
                echo "jQuery('#region').hide();";
            }
            echo "jQuery('#region_select_{$form_id}').html('');\n\r";
            echo "\n\t\t\t\tvar wpsc_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpsc_checkout_table').attr('class');\n\t\t\t\twpsc_checkout_table_selector = wpsc_checkout_table_selector.replace(' ','.');\n\t\t\t\twpsc_checkout_table_selector = '.'+wpsc_checkout_table_selector;\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.billing_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.shipping_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .billing_region').parent().parent().show();\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .shipping_region').parent().parent().show();\n\t\t\t";
        }
    }
    if ($tax > 0) {
        echo "jQuery(\"tr.total_tax\").show();\n\r";
    } else {
        echo "jQuery(\"tr.total_tax\").hide();\n\r";
    }
    echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>" . wpsc_cart_tax() . "</span>\");\n\r";
    echo "jQuery('#checkout_total').html(\"{$total}<input id='shopping_cart_total_price' type='hidden' value='{$total_input}' />\");\n\r";
    echo "if(jQuery(\"#shippingSameBilling\").is(\":checked\")) wpsc_shipping_same_as_billing();";
    exit;
}
예제 #10
0
/**
 * Sale price column in Manage Products page.
 *
 * @since  3.8.9
 * @access private
 * @param  object  $post           Post object
 * @param  int     $post_id        Post ID
 * @param  boolean $has_variations Whether the product has variations
 */
function _wpsc_manage_products_column_sale_price($post, $post_id, $has_variations)
{
    $price = get_post_meta($post->ID, '_wpsc_special_price', true);
    if (!$has_variations) {
        echo wpsc_currency_display($price);
        echo '<div id="inline_' . $post->ID . '_sale_price" class="hidden">' . $price . '</div>';
    } else {
        echo wpsc_product_variation_price_available($post->ID) . '+';
    }
}
function wpsc_user_purchases()
{
    global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields, $purchase_log, $col_count, $nzshpcrt_gateways;
    $i = 0;
    $subtotal = 0;
    do_action('wpsc_pre_purchase_logs');
    foreach ((array) $purchase_log as $purchase) {
        $status_state = "expand";
        $status_style = "display:none;";
        $alternate = "";
        $i++;
        if ($i % 2 != 0) {
            $alternate = "alt";
        }
        echo "<tr class='{$alternate}'>\n\r";
        echo " <td class='status processed'>";
        echo "<a href=\"#\" onclick=\"return show_details_box('status_box_" . $purchase['id'] . "','log_expander_icon_" . $purchase['id'] . "');\">";
        if (!empty($_GET['id']) && $_GET['id'] == $purchase['id']) {
            $status_state = "collapse";
            $status_style = "style='display: block;'";
        }
        echo "<img class=\"log_expander_icon\" id=\"log_expander_icon_" . $purchase['id'] . "\" src=\"" . WPSC_CORE_IMAGES_URL . "/icon_window_{$status_state}.gif\" alt=\"\" title=\"\" />";
        echo "<span id='form_group_" . $purchase['id'] . "_text'>" . __('Details', 'wpsc') . "</span>";
        echo "</a>";
        echo " </td>\n\r";
        echo " <td class='date'>";
        echo date("jS M Y", $purchase['date']);
        echo " </td>\n\r";
        echo " <td class='price'>";
        $country = get_option('country_form_field');
        if ($purchase['shipping_country'] != '') {
            $billing_country = $purchase['billing_country'];
            $shipping_country = $purchase['shipping_country'];
        } elseif (!empty($country)) {
            $country_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = %d LIMIT 1", $purchase['id'], get_option('country_form_field'));
            $country_data = $wpdb->get_results($country_sql, ARRAY_A);
            $billing_country = $country_data[0]['value'];
            $shipping_country = $country_data[0]['value'];
        }
        echo wpsc_currency_display($purchase['totalprice'], array('display_as_html' => false));
        $subtotal += $purchase['totalprice'];
        echo " </td>\n\r";
        if (get_option('payment_method') == 2) {
            echo " <td class='payment_method'>";
            $gateway_name = '';
            foreach ((array) $nzshpcrt_gateways as $gateway) {
                if ($purchase['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purchase['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = __("Manual Payment", 'wpsc');
                }
            }
            echo $gateway_name;
            echo " </td>\n\r";
        }
        echo "</tr>\n\r";
        echo "<tr>\n\r";
        echo " <td colspan='{$col_count}' class='details'>\n\r";
        echo "  <div id='status_box_" . $purchase['id'] . "' class='order_status' style=\"{$status_style}\">\n\r";
        echo "  <div>\n\r";
        //order status code lies here
        //check what $purchase['processed'] reflects in the $wpsc_purchlog_statuses array
        $status_name = wpsc_find_purchlog_status_name($purchase['processed']);
        echo "  <strong class='form_group'>" . __('Order Status', 'wpsc') . ":</strong>\n\r";
        echo $status_name . "<br /><br />";
        do_action('wpsc_user_log_after_order_status', $purchase);
        //written by allen
        $usps_id = get_option('usps_user_id');
        if ($usps_id != null) {
            $XML1 = "<TrackFieldRequest USERID=\"{$usps_id}\"><TrackID ID=\"" . $purchase['track_id'] . "\"></TrackID></TrackFieldRequest>";
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "http://secure.shippingapis.com/ShippingAPITest.dll?");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            $postdata = "API=TrackV2&XML=" . $XML1;
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
            $parser = new xml2array();
            $parsed = $parser->parse($result);
            $parsed = $parsed[0]['children'][0]['children'];
            if ($purchase['track_id'] != null) {
                echo "<br /><br />";
                echo " <strong class='form_group'>" . __('Shipping Address', 'wpsc') . "</strong>\n\r";
                echo "<table>";
                foreach ((array) $parsed as $parse) {
                    if ($parse['name'] == "TRACKSUMMARY") {
                        foreach ((array) $parse['children'] as $attrs) {
                            if ($attrs['name'] != "EVENT") {
                                $attrs['name'] = str_replace("EVENT", "", $attrs['name']);
                            }
                            $bar = ucfirst(strtolower($attrs['name']));
                            echo "<tr><td>" . $bar . "</td><td>" . $attrs['tagData'] . "</td></tr>";
                        }
                    }
                }
                echo "</table>";
            }
            echo "<br /><br />";
        }
        //end of written by allen
        //cart contents display starts here;
        echo "  <strong class='form_group'>" . __('Order Details', 'wpsc') . ":</strong>\n\r";
        $cartsql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`= %d", $purchase['id']);
        $cart_log = $wpdb->get_results($cartsql, ARRAY_A);
        $j = 0;
        // /*
        if ($cart_log != null) {
            echo "<table class='logdisplay'>";
            echo "<tr class='toprow2'>";
            echo " <th class='details_name'>";
            _e('Name', 'wpsc');
            echo " </th>";
            echo " <th class='details_quantity'>";
            _e('Quantity', 'wpsc');
            echo " </th>";
            echo " <th class='details_price'>";
            _e('Price', 'wpsc');
            echo " </th>";
            echo " <th class='details_tax'>";
            _e('GST', 'wpsc');
            echo " </th>";
            echo " <th class='details_shipping'>";
            _e('Shipping', 'wpsc');
            echo " </th>";
            echo " <th class='details_total'>";
            _e('Total', 'wpsc');
            echo " </th>";
            echo "</tr>";
            $gsttotal = false;
            $endtotal = $total_shipping = 0;
            foreach ((array) $cart_log as $cart_row) {
                $alternate = "";
                $j++;
                if ($j % 2 != 0) {
                    $alternate = "alt";
                }
                $variation_list = '';
                $billing_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : '';
                $shipping_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : '';
                $shipping = $cart_row['pnp'];
                $total_shipping += $shipping;
                echo "<tr class='{$alternate}'>";
                echo " <td class='details_name'>";
                echo apply_filters('the_title', $cart_row['name']);
                echo $variation_list;
                echo " </td>";
                echo " <td class='details_quantity'>";
                echo $cart_row['quantity'];
                echo " </td>";
                echo " <td class='details_price'>";
                $price = $cart_row['price'] * $cart_row['quantity'];
                echo wpsc_currency_display($price);
                echo " </td>";
                echo " <td class='details_tax'>";
                $gst = $cart_row['tax_charged'];
                if ($gst > 0) {
                    $gsttotal += $gst;
                }
                echo wpsc_currency_display($gst, array('display_as_html' => false));
                echo " </td>";
                echo " <td class='details_shipping'>";
                echo wpsc_currency_display($shipping, array('display_as_html' => false));
                echo " </td>";
                echo " <td class='details_total'>";
                $endtotal += $price;
                echo wpsc_currency_display($shipping + $price, array('display_as_html' => false));
                echo " </td>";
                echo '</tr>';
            }
            echo "<tr>";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " <td>";
            echo " </td>";
            echo " </td>";
            echo " <td class='details_totals_labels'>";
            echo "<strong>" . __('Total Shipping', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Total Tax', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Final Total', 'wpsc') . ":</strong>";
            echo " </td>";
            echo " <td class='details_totals_labels'>";
            $total_shipping += $purchase['base_shipping'];
            $endtotal += $total_shipping;
            $endtotal += $purchase['wpec_taxes_total'];
            echo wpsc_currency_display($total_shipping, array('display_as_html' => false)) . "<br />";
            if ($gsttotal) {
                //if false then must be exclusive.. doesnt seem too reliable needs more testing
                echo wpsc_currency_display($gsttotal, array('display_as_html' => false)) . "<br />";
            } else {
                echo wpsc_currency_display($purchase['wpec_taxes_total'], array('display_as_html' => false)) . "<br />";
            }
            echo wpsc_currency_display($endtotal, array('display_as_html' => false));
            echo " </td>";
            echo '</tr>';
            echo "</table>";
            echo "<br />";
            echo "<strong>" . __('Customer Details', 'wpsc') . ":</strong>";
            echo "<table class='customer_details'>";
            $usersql = $wpdb->prepare("SELECT `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.value, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.* FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` ON `" . WPSC_TABLE_CHECKOUT_FORMS . "`.id = `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.`form_id` WHERE `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.log_id = %d OR `" . WPSC_TABLE_CHECKOUT_FORMS . "`.type = 'heading' ORDER BY `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`checkout_set`, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`checkout_order`", $purchase['id']);
            $formfields = $wpdb->get_results($usersql, ARRAY_A);
            if (!empty($formfields)) {
                foreach ((array) $formfields as $form_field) {
                    // If its a heading display the Name otherwise continue on
                    if ('heading' == $form_field['type']) {
                        echo "  <tr><td colspan='2'>" . esc_html($form_field['name']) . ":</td></tr>";
                        continue;
                    }
                    switch ($form_field['unique_name']) {
                        case 'shippingcountry':
                        case 'billingcountry':
                            $country = maybe_unserialize($form_field['value']);
                            if (is_array($country)) {
                                $country = $country[0];
                            } else {
                                $country = $form_field['value'];
                            }
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($country) . "</td></tr>";
                            break;
                        case 'billingstate':
                        case 'shippingstate':
                            if (is_numeric($form_field['value'])) {
                                $state = wpsc_get_state_by_id($form_field['value'], 'name');
                            } else {
                                $state = $form_field['value'];
                            }
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($state) . "</td></tr>";
                            break;
                        default:
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($form_field['value']) . "</td></tr>";
                    }
                }
            }
            $payment_gateway_names = '';
            $payment_gateway_names = get_option('payment_gateway_names');
            foreach ((array) $payment_gateway_names as $gatewayname) {
                //if the gateway has a custom name
                if (!empty($gatewayname)) {
                    $display_name = $payment_gateway_names[$purchase_log[0]['gateway']];
                } else {
                    //if not fall back on default name
                    foreach ((array) $nzshpcrt_gateways as $gateway) {
                        if ($gateway['internalname'] == $purchase['gateway']) {
                            $display_name = $gateway['name'];
                        }
                    }
                }
            }
            echo "  <tr><td>" . __('Payment Method', 'wpsc') . ":</td><td>" . $display_name . "</td></tr>";
            echo "  <tr><td>" . __('Purchase #', 'wpsc') . ":</td><td>" . $purchase['id'] . "</td></tr>";
            if ($purchase['transactid'] != '') {
                echo "  <tr><td>" . __('Transaction Id', 'wpsc') . ":</td><td>" . $purchase['transactid'] . "</td></tr>";
            }
            echo "</table>";
        }
        echo "  </div>\n\r";
        echo "  </div>\n\r";
        echo " </td>\n\r";
        echo "</tr>\n\r";
    }
}
예제 #12
0
파일: cart.php 프로젝트: ashik968/digiplot
/**
* cart item shipping function, no parameters
* @return string the cart item price multiplied by the quantity, with a currency sign
*/
function wpsc_cart_item_shipping($forDisplay = true)
{
    global $wpsc_cart;
    if ($forDisplay) {
        return wpsc_currency_display($wpsc_cart->cart_item->shipping);
    } else {
        return $wpsc_cart->cart_item->shipping;
    }
}
예제 #13
0
 /**
  * process_as_currency method
  *
  * @access public
  *
  * @param float a price
  * @return string a price with a currency sign
  */
 function process_as_currency($price)
 {
     _wpsc_deprecated_function(__FUNCTION__, '3.8', 'wpsc_currency_display');
     return wpsc_currency_display($price);
 }
 public function add_pushes($session_id)
 {
     global $wpdb;
     $purchase = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $session_id));
     $purchase_id = $purchase->id;
     $output = '';
     $city = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT tf.value FROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " tf\n\t\t\t\t\t\tLEFT JOIN " . WPSC_TABLE_CHECKOUT_FORMS . " cf\n\t\t\t\t\t\tON cf.id = tf.form_id\n\t\t\t\t\t\tWHERE cf.unique_name = 'billingcity'\n\t\t\t\t\t\tAND log_id = %d", $purchase_id));
     $state = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT tf.value\n\t\t\t\t\t\tFROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " tf\n\t\t\t\t\t\tLEFT JOIN " . WPSC_TABLE_CHECKOUT_FORMS . " cf\n\t\t\t\t\t\tON cf.id = tf.form_id\n\t\t\t\t\t\tWHERE cf.unique_name = 'billingstate'\n\t\t\t\t\t\tAND log_id = %d", $purchase_id));
     $country = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT tf.value\n\t\t\t\t\t\tFROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " tf\n\t\t\t\t\t\tLEFT JOIN " . WPSC_TABLE_CHECKOUT_FORMS . " cf\n\t\t\t\t\t\tON cf.id = tf.form_id\n\t\t\t\t\t\tWHERE cf.unique_name = 'billingcountry'\n\t\t\t\t\t\tAND log_id = %d", $purchase_id));
     $city = !empty($city) ? $city : '';
     $state = !empty($state) ? wpsc_get_state_by_id($state, 'name') : '';
     $country = !empty($country) ? $country : '';
     $cart_items = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . WPSC_TABLE_CART_CONTENTS . " WHERE purchaseid = %d", $purchase_id), ARRAY_A);
     $total_shipping = wpsc_get_total_shipping($purchase_id);
     $total_tax = $total_price = 0;
     foreach ($cart_items as $item) {
         $total_tax += $item['tax_charged'];
         $total_price += $item['price'];
     }
     if ($this->is_theme_tracking || $this->advanced_code) {
         $output .= "<script type='text/javascript'>\n\r";
     }
     add_filter('wpsc_toggle_display_currency_code', array($this, 'remove_currency_and_html'));
     $output .= "\n\t\t\t_gaq.push(['_addTrans',\n\t\t\t'" . $purchase_id . "',                                     // order ID - required\n\t\t\t'" . wp_specialchars_decode($this->get_site_name()) . "', // affiliation or store name\n\t\t\t'" . number_format($total_price, 2, '.', '') . "',   // total - required\n\t\t\t'" . wpsc_currency_display($total_tax) . "',              // tax\n\t\t\t'" . wpsc_currency_display($total_shipping) . "',         // shipping\n\t\t\t'" . wp_specialchars_decode($city) . "',                  // city\n\t\t\t'" . wp_specialchars_decode($state) . "',                 // state or province\n\t\t\t'" . wp_specialchars_decode($country) . "'                // country\n  \t\t]);\n\r";
     remove_filter('wpsc_toggle_display_currency_code', array($this, 'remove_currency_and_html'));
     foreach ($cart_items as $item) {
         $category = wp_get_object_terms($item['prodid'], 'wpsc_product_category', array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'all_with_object_id'));
         $item['sku'] = get_post_meta($item['prodid'], '_wpsc_sku', true);
         if ($category) {
             $item['category'] = $category[0]->name;
         } else {
             $item['category'] = '';
         }
         $item = array_map('wp_specialchars_decode', $item);
         $output .= "_gaq.push(['_addItem'," . "'" . $purchase_id . "'," . "'" . $item['sku'] . "'," . "'" . $item['name'] . "'," . "'" . $item['category'] . "'," . "'" . $item['price'] . "'," . "'" . $item['quantity'] . "']);\n\r";
         // Item Quantity
     }
     $output .= "_gaq.push(['_trackTrans']);\n\r";
     if ($this->is_theme_tracking || $this->advanced_code) {
         $output .= "</script>\n\r";
     }
     return $output;
 }
예제 #15
0
파일: json.php 프로젝트: bulats/chef
function get_last_few_order_details($product_id, $select, $from, $group_by, $where)
{
    global $wpdb, $cat_rev, $months, $order_arr;
    $select .= ",wtcc.purchaseid as PurchaseID,wtpl.date as date,wtpl.totalprice as totalprice";
    $select .= ",(select concat(a.value,' ',b.value) from {$wpdb->prefix}wpsc_submited_form_data as a \n\t\t\t\t\tJoin {$wpdb->prefix}wpsc_submited_form_data as b\n\t\t\t\t\twhere a.form_id=(select id from {$wpdb->prefix}wpsc_checkout_forms where unique_name like 'billingfirstname')\n\t\t\t\t\tand b.form_id=(select id from {$wpdb->prefix}wpsc_checkout_forms where unique_name like 'billinglastname')\n\t\t\t\t\tand a.log_id=PurchaseID and b.log_id=PurchaseID) as cname";
    $order_by = "ORDER BY date DESC";
    $limit = "limit 0,5";
    if (isset($product_id)) {
        $group_by .= "GROUP BY PurchaseID";
    }
    if (isset($product_id) && $product_id != 0) {
        $where .= " AND prodid = {$product_id} ";
    }
    $query = "{$select} {$from} {$where} {$group_by} {$order_by} {$limit}";
    $results = $wpdb->get_results($query, 'ARRAY_A');
    $num_rows = $wpdb->num_rows;
    $no_records = $num_rows;
    if ($no_records == 0) {
        $encoded['orderDetails']['order'] = '';
        $encoded['orderDetails']['orderTotalCount'] = 0;
    } else {
        $cnt = 0;
        $order_data = array();
        foreach ($results as $result) {
            // put within condition
            $order_data[$cnt]['purchaseid'] = $result['PurchaseID'];
            $order_data[$cnt]['date'] = date("d-M-Y", $result['date']);
            $order_data[$cnt]['totalprice'] = wpsc_currency_display($result['totalprice']);
            $order_data[$cnt]['cname'] = $result['cname'];
            $orders[] = $order_data[$cnt];
            $cnt++;
        }
        $encoded['orderDetails']['order'] = $orders;
        $encoded['orderDetails']['orderTotalCount'] = count($orders);
    }
    return $encoded;
}
function vtprd_show_product_you_save($product_id = null)
{
    global $post, $vtprd_setup_options, $vtprd_info;
    //can only be executed when WPEC version less than 3.8.9
    if (!(version_compare(strval('3.8.9'), strval(WPSC_VERSION), '>') == 1)) {
        //'==1' = 2nd value is lower
        return;
    }
    $pct = vtprd_get_single_product_you_save_pct($product_id);
    $amt = $vtprd_info['product_session_info']['product_yousave_total_amt'];
    $amt = vtprd_format_money_element($amt);
    //CUSTOM function created by CUSTOMER
    if (function_exists('custom_show_single_product_you_save')) {
        custom_show_single_product_you_save($product_id, $pct, $amt);
        return;
    }
    if ($pct) {
        ?>
				<p class="pricedisplay product_<?php 
        echo wpsc_the_product_id();
        ?>
"><?php 
        _e('You save', 'wpsc');
        ?>
: <span class="yousave" id="yousave_<?php 
        echo wpsc_the_product_id();
        ?>
"><?php 
        echo $amt;
        ?>
! (<?php 
        echo $pct;
        ?>
%)</span></p>
			<?php 
    } else {
        //original code from wpsc-single_product.php
        ?>
      
        <?php 
        if (wpsc_product_on_special()) {
            ?>
					<p class="pricedisplay product_<?php 
            echo wpsc_the_product_id();
            ?>
"><?php 
            _e('You save', 'wpsc');
            ?>
: <span class="yousave" id="yousave_<?php 
            echo wpsc_the_product_id();
            ?>
"><?php 
            echo wpsc_currency_display(wpsc_you_save('type=amount'), array('html' => false));
            ?>
! (<?php 
            echo wpsc_you_save();
            ?>
%)</span></p>
				<?php 
        }
        ?>
      
      <?php 
    }
    return;
}
예제 #17
0
/**
 * Spits out the current products details in a table row for manage products page and variations on edit product page.
 * @access public
 *
 * @since 3.8
 * @param $product (Object), $parent_product (Int) Note: I believe parent_product is unused
 */
function wpsc_product_row(&$product, $parent_product = null)
{
    global $mode, $current_user, $wpsc_products;
    //is this good practice? <*****@*****.**>
    static $rowclass, $object_terms_cache = array();
    // store terms associated with variants inside a cache array. This only requires 1 DB query.
    if (empty($object_terms_cache)) {
        $ids = wp_list_pluck($wpsc_products, 'ID');
        $object_terms = wp_get_object_terms($ids, 'wpsc-variation', array('fields' => 'all_with_object_id'));
        foreach ($object_terms as $term) {
            if (!array_key_exists($term->object_id, $object_terms_cache)) {
                $object_terms_cache[$term->object_id] = array();
            }
            $object_terms_cache[$term->object_id][$term->parent] = $term->name;
        }
    }
    $global_product = $product;
    setup_postdata($product);
    $product_post_type_object = get_post_type_object('wpsc-product');
    $current_user_can_edit_this_product = current_user_can($product_post_type_object->cap->edit_post, $product->ID);
    $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
    $post_owner = $current_user->ID == $product->post_author ? 'self' : 'other';
    $edit_link = get_edit_post_link($product->ID);
    if (isset($object_terms_cache[$product->ID])) {
        ksort($object_terms_cache[$product->ID]);
        $title = implode(', ', $object_terms_cache[$product->ID]);
    } else {
        $title = get_the_title($product->ID);
    }
    if (empty($title)) {
        $title = __('(no title)', 'wpsc');
    }
    ?>

	<tr id='post-<?php 
    echo $product->ID;
    ?>
' class='<?php 
    echo trim($rowclass . ' author-' . $post_owner . ' status-' . $product->post_status);
    ?>
 iedit <?php 
    if (get_option('wpsc_sort_by') == 'dragndrop') {
        echo 'product-edit';
    }
    ?>
' valign="top">
	<?php 
    $posts_columns = get_column_headers('wpsc-product_variants');
    if (empty($posts_columns)) {
        $posts_columns = array('image' => '', 'title' => __('Name', 'wpsc'), 'weight' => __('Weight', 'wpsc'), 'stock' => __('Stock', 'wpsc'), 'price' => __('Price', 'wpsc'), 'sale_price' => __('Sale Price', 'wpsc'), 'SKU' => __('SKU', 'wpsc'), 'hidden_alerts' => '');
    }
    foreach ($posts_columns as $column_name => $column_display_name) {
        $attributes = "class=\"{$column_name} column-{$column_name}\"";
        switch ($column_name) {
            case 'date':
                /* !date case */
                if ('0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name) {
                    $t_time = $h_time = __('Unpublished', 'wpsc');
                    $time_diff = 0;
                } else {
                    $t_time = get_the_time(__('Y/m/d g:i:s A', 'wpsc'));
                    $m_time = $product->post_date;
                    $time = get_post_time('G', true, $post);
                    $time_diff = time() - $time;
                    if ($time_diff > 0 && $time_diff < 24 * 60 * 60) {
                        $h_time = sprintf(__('%s ago', 'wpsc'), human_time_diff($time));
                    } else {
                        $h_time = mysql2date(__('Y/m/d', 'wpsc'), $m_time);
                    }
                }
                echo '<td ' . $attributes . '>';
                if ('excerpt' == $mode) {
                    echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
                } else {
                    echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
                }
                echo '<br />';
                if ('publish' == $product->post_status) {
                    _e('Published', 'wpsc');
                } elseif ('future' == $product->post_status) {
                    if ($time_diff > 0) {
                        echo '<strong class="attention">' . __('Missed schedule', 'wpsc') . '</strong>';
                    } else {
                        _e('Scheduled', 'wpsc');
                    }
                } else {
                    _e('Last Modified', 'wpsc');
                }
                echo '</td>';
                break;
            case 'title':
                /* !title case */
                $attributes = 'class="post-title column-title"';
                $edit_link = wp_nonce_url($edit_link, 'edit-product_' . $product->ID);
                ?>
		<td <?php 
                echo $attributes;
                ?>
>
			<strong>
			<?php 
                if ($current_user_can_edit_this_product && $product->post_status != 'trash') {
                    ?>
				<span><a class="row-title" href="<?php 
                    echo $edit_link;
                    ?>
" title="<?php 
                    echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;', 'wpsc'), $title));
                    ?>
"><?php 
                    echo $title;
                    ?>
</a></span>
				<?php 
                    if ($parent_product) {
                        ?>
					<a href="<?php 
                        echo $edit_link;
                        ?>
" title="<?php 
                        echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;', 'wpsc'), $title));
                        ?>
"><?php 
                        echo $title;
                        ?>
</a>

				<?php 
                    }
                    ?>
			<?php 
                } else {
                    echo $title;
                }
                _post_states($product);
                $product_alert = apply_filters('wpsc_product_alert', array(false, ''), $product);
                if (!empty($product_alert['messages'])) {
                    $product_alert['messages'] = implode("\n", (array) $product_alert['messages']);
                }
                if ($product_alert['state'] === true) {
                    ?>
				<img alt='<?php 
                    echo $product_alert['messages'];
                    ?>
' title='<?php 
                    echo $product_alert['messages'];
                    ?>
' class='product-alert-image' src='<?php 
                    echo WPSC_CORE_IMAGES_URL;
                    ?>
/product-alert.jpg' alt='' />
				<?php 
                }
                // If a product alert has stuff to display, show it.
                // Can be used to add extra icons etc
                if (!empty($product_alert['display'])) {
                    echo $product_alert['display'];
                }
                ?>
			</strong>
			<?php 
                $has_var = '';
                if (!$parent_product && wpsc_product_has_children($product->ID)) {
                    $has_var = 'wpsc_has_variation';
                }
                $actions = array();
                if ($current_user_can_edit_this_product && 'trash' != $product->post_status) {
                    $actions['edit'] = '<a class="edit-product" href="' . $edit_link . '" title="' . esc_attr(__('Edit this product', 'wpsc')) . '">' . __('Edit', 'wpsc') . '</a>';
                    //commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link.
                    //$actions['quick_edit'] = "<a class='wpsc_editinline ".$has_var."' title='".esc_attr(__('Quick Edit', 'wpsc'))."' href='#'>".__('Quick Edit', 'wpsc')."</a>";
                }
                $actions = apply_filters('post_row_actions', $actions, $product);
                $action_count = count($actions);
                $i = 0;
                echo '<div class="row-actions">';
                foreach ($actions as $action => $link) {
                    ++$i;
                    $i == $action_count ? $sep = '' : ($sep = ' | ');
                    echo "<span class='{$action}'>{$link}{$sep}</span>";
                }
                echo '</div>';
                ?>
		</td>
		<?php 
                break;
            case 'image':
                /* !image case */
                ?>
			<td class="product-image ">
			<?php 
                $attachment_args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $product->ID, 'orderby' => 'menu_order', 'order' => 'ASC');
                if (isset($product->ID) && has_post_thumbnail($product->ID)) {
                    echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails');
                } else {
                    $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
                    ?>
					<img title='Drag to a new position' src='<?php 
                    echo $image_url;
                    ?>
' alt='<?php 
                    echo $title;
                    ?>
' width='38' height='38' />
				<?php 
                }
                ?>
			</td>
			<?php 
                break;
            case 'price':
                /* !price case */
                $price = get_product_meta($product->ID, 'price', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<?php 
                echo wpsc_currency_display($price);
                ?>
					<input type="text" class="wpsc_ie_field wpsc_ie_price" value="<?php 
                echo $price;
                ?>
">
					<a href="<?php 
                echo $edit_link;
                ?>
/#wpsc_downloads">Variant Download Files</a>
				</td>
			<?php 
                break;
            case 'weight':
                $product_data['meta'] = array();
                $product_data['meta'] = get_post_meta($product->ID, '');
                foreach ($product_data['meta'] as $meta_name => $meta_value) {
                    $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
                }
                $product_data['transformed'] = array();
                if (!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) {
                    $product_data['meta']['_wpsc_product_metadata']['weight'] = "";
                }
                if (!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) {
                    $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
                }
                $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'], false);
                $weight = $product_data['transformed']['weight'];
                if ($weight == '') {
                    $weight = '0';
                }
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo $weight;
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_weight" value="<?php 
                echo $weight;
                ?>
">
					<a href="<?php 
                echo $edit_link;
                ?>
/#wpsc_tax">Set Variant Tax</a>
				</td>
			<?php 
                break;
            case 'stock':
                $stock = get_post_meta($product->ID, '_wpsc_stock', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo $stock ? $stock : __('N/A', 'wpsc');
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_stock" value="<?php 
                echo $stock;
                ?>
">
					<a href="<?php 
                echo $edit_link;
                ?>
/#wpsc_shipping">Set Variant Shipping</a>
				</td>
	<?php 
                break;
            case 'categories':
                /* !categories case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><?php 
                $categories = get_the_product_category($product->ID);
                if (!empty($categories)) {
                    $out = array();
                    foreach ($categories as $c) {
                        $out[] = "<a href='admin.php?page=wpsc-edit-products&amp;category={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
                    }
                    echo join(', ', $out);
                } else {
                    _e('Uncategorized', 'wpsc');
                }
                ?>
</td>
		<?php 
                break;
            case 'tags':
                /* !tags case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><?php 
                $tags = get_the_tags($product->ID);
                if (!empty($tags)) {
                    $out = array();
                    foreach ($tags as $c) {
                        $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
                    }
                    echo join(', ', $out);
                } else {
                    _e('No Tags', 'wpsc');
                }
                ?>
</td>
		<?php 
                break;
            case 'SKU':
                $sku = get_post_meta($product->ID, '_wpsc_sku', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo $sku ? $sku : __('N/A', 'wpsc');
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_sku" value="<?php 
                echo $sku;
                ?>
">
										<input type="hidden" class="wpsc_ie_id wpsc_ie_field" value="<?php 
                echo $product->ID;
                ?>
">
					<div class="wpsc_inline_actions"><input type="button" class="button-primary wpsc_ie_save" value="Save"><img src="<?php 
                echo admin_url('images/wpspin_light.gif');
                ?>
" class="loading_indicator"><br/></div>
				</td>
			<?php 
                break;
            case 'sale_price':
                $sale_price = get_post_meta($product->ID, '_wpsc_special_price', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo wpsc_currency_display($sale_price);
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_special_price" value="<?php 
                echo $sale_price;
                ?>
">
				</td>
			<?php 
                break;
            case 'comments':
                /* !comments case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><div class="post-com-count-wrapper">
		<?php 
                $pending_phrase = sprintf(__('%s pending', 'wpsc'), number_format($pending_comments));
                if ($pending_comments) {
                    echo '<strong>';
                }
                comments_number("<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count', 'wpsc') . '</span></a>', "<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count', 'wpsc') . '</span></a>', "<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count', 'wpsc') . '</span></a>');
                if ($pending_comments) {
                    echo '</strong>';
                }
                ?>
		</div></td>
		<?php 
                break;
            case 'author':
                /* !author case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><a href="edit.php?author=<?php 
                the_author_meta('ID');
                ?>
"><?php 
                the_author();
                ?>
</a></td>
		<?php 
                break;
            case 'control_view':
                /* !control view case */
                ?>
		<td><a href="<?php 
                the_permalink();
                ?>
" rel="permalink" class="view"><?php 
                _e('View', 'wpsc');
                ?>
</a></td>
		<?php 
                break;
            case 'control_edit':
                /* !control edit case */
                ?>
		<td><?php 
                if ($current_user_can_edit_this_product) {
                    echo "<a href='{$edit_link}' class='edit'>" . __('Edit', 'wpsc') . "</a>";
                }
                ?>
</td>
		<?php 
                break;
            case 'control_delete':
                /* !control delete case */
                ?>
		<td><?php 
                if ($current_user_can_edit_this_product) {
                    echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post={$id}", 'delete-post_' . $product->ID) . "' class='delete'>" . __('Delete', 'wpsc') . "</a>";
                }
                ?>
</td>
		<?php 
                break;
            case 'featured':
                /* !control featured case */
                ?>
			<td><?php 
                do_action('manage_posts_featured_column', $product->ID);
                ?>
</td>
		<?php 
                break;
            default:
                /* !default case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><?php 
                do_action('manage_posts_custom_column', $column_name, $product->ID);
                ?>
</td>
		<?php 
                break;
        }
    }
    ?>
	</tr>
<?php 
    $product = $global_product;
}
예제 #18
0
function wpsc_right_now()
{
    global $wpdb;
    $year = date("Y");
    $month = date("m");
    $start_timestamp = mktime(0, 0, 0, $month, 1, $year);
    $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year);
    $product_count = $wpdb->get_var("SELECT COUNT(*)\n\t\tFROM `" . $wpdb->posts . "`\n\t\tWHERE `post_status` = 'publish'\n\t\tAND `post_type` = 'wpsc-product'");
    $group_count = count(get_terms("wpsc_product_category"));
    $sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $start_timestamp . "' AND '" . $end_timestamp . "'");
    $monthtotal = wpsc_currency_display(admin_display_total_price($start_timestamp, $end_timestamp));
    $overaltotal = wpsc_currency_display(admin_display_total_price());
    $variation_count = count(get_terms("wpsc-variation", array('parent' => 0)));
    $pending_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('1','2')");
    $accept_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('3' ,'4', '5')");
    $theme = get_option('wpsc_selected_theme');
    ?>
	<div class='table'>
		<p class='sub'><?php 
    esc_html_e('At a Glance', 'wp-e-commerce');
    ?>
</p>
		<table style='border-top:1px solid #ececec;'>
			<tr class='first'>
				<td class='first b'>
					<?php 
    echo $product_count;
    ?>
				</td>
				<td class='t'>
					<?php 
    echo _nx('Product', 'Products', $product_count, 'dashboard widget', 'wp-e-commerce');
    ?>
				</td>
				<td class='b'>
					<?php 
    echo $sales_count;
    ?>
				</td>
				<td class='last'>
					<?php 
    echo _nx('Sale', 'Sales', $sales_count, 'dashboard widget', 'wp-e-commerce');
    ?>
				</td>
			</tr>
			<tr>
				<td class='first b'>
					<?php 
    echo $group_count;
    ?>
				</td>
				<td class='t'>
					<?php 
    echo _nx('Category', 'Categories', $group_count, 'dashboard widget', 'wp-e-commerce');
    ?>
				</td>
				<td class='b'>
					<?php 
    echo $pending_sales;
    ?>
				</td>
				<td class='last t waiting'>
					<?php 
    echo _n('Pending sale', 'Pending sales', $pending_sales, 'wp-e-commerce');
    ?>
				</td>
			</tr>
			<tr>
				<td class='first b'>
					<?php 
    echo $variation_count;
    ?>
				</td>
				<td class='t'>
					<?php 
    echo _nx('Variation', 'Variations', $variation_count, 'dashboard widget', 'wp-e-commerce');
    ?>
				</td>
				<td class='b'>
					<?php 
    echo $accept_sales;
    ?>
				</td>
				<td class='last t approved'>
					<?php 
    echo _n('Closed sale', 'Closed sales', $accept_sales, 'wp-e-commerce');
    ?>
				</td>
			</tr>
		</table>
	</div>
	<?php 
}
예제 #19
0
function wpsc_the_product_price_display($args = array())
{
    if (empty($args['id'])) {
        $id = get_the_ID();
    } else {
        $id = (int) $args['id'];
    }
    $defaults = array('id' => $id, 'old_price_text' => __('Old Price: %s', 'wp-e-commerce'), 'price_text' => __('Price: %s', 'wp-e-commerce'), 'you_save_text' => __('You save: %s', 'wp-e-commerce'), 'old_price_class' => 'pricedisplay wpsc-product-old-price ' . $id, 'old_price_before' => '<p %s>', 'old_price_after' => '</p>', 'old_price_amount_id' => 'old_product_price_' . $id, 'old_price_amount_class' => 'oldprice', 'old_price_amount_before' => '<span class="%1$s" id="%2$s">', 'old_price_amount_after' => '</span>', 'price_amount_id' => 'product_price_' . $id, 'price_class' => 'pricedisplay wpsc-product-price ' . $id, 'price_before' => '<p %s>', 'price_after' => '</p>', 'price_amount_class' => 'currentprice pricedisplay ' . $id, 'price_amount_before' => '<span class="%1$s" id="%2$s">', 'price_amount_after' => '</span>', 'you_save_class' => 'pricedisplay wpsc-product-you-save product_' . $id, 'you_save_before' => '<p %s>', 'you_save_after' => '</p>', 'you_save_amount_id' => 'yousave_' . $id, 'you_save_amount_class' => 'yousave', 'you_save_amount_before' => '<span class="%1$s" id="%2$s">', 'you_save_amount_after' => '</span>', 'output_price' => true, 'output_old_price' => true, 'output_you_save' => true);
    $r = wp_parse_args($args, $defaults);
    /**
     * wpsc_the_product_price_display_args filter args for product price display
     *
     * Paramters used to format price display can be set globally using this filter
     *
     * @since 4.0
     *
     * @type array $args array of parameters used to format product price
     * @type int $product_id WPeC Product ID for the current product
     */
    $r = apply_filters('wpsc_the_product_price_display_args', $r, $id);
    extract($r);
    // if the product has no variations, these amounts are straight forward...
    $old_price = wpsc_product_normal_price($id);
    $current_price = wpsc_the_product_price(false, false, $id);
    $you_save = wpsc_you_save(array('type' => 'amount', 'product_id' => $id));
    $show_old_price = $show_you_save = wpsc_product_on_special($id);
    // Don't output old price HTML if not on sale.
    if (!wpsc_product_on_special($id)) {
        $output_old_price = $output_you_save = false;
    }
    // but if the product has variations and at least one of the variations is on special, we have
    // a few edge cases...
    if (wpsc_product_has_variations($id) && wpsc_product_on_special($id)) {
        // generally it doesn't make sense to display "you save" amount unless the user has selected
        // a specific variation
        $show_you_save = false;
        $old_price_number = wpsc_product_variation_price_from($id, array('only_normal_price' => true));
        $current_price_number = wpsc_product_variation_price_from($id);
        // if coincidentally, one of the variations are not on special, but its price is equal to
        // or lower than the lowest variation sale price, old price should be hidden, and current
        // price should reflect the "normal" price, not the sales price, to avoid confusion
        if ($old_price_number == $current_price_number) {
            $show_old_price = false;
            $current_price = wpsc_product_normal_price($id);
        }
    }
    // replace placeholders in arguments with correct values
    $old_price_class = apply_filters('wpsc_the_product_price_display_old_price_class', $old_price_class, $id);
    $old_price_amount_class = apply_filters('wpsc_the_product_price_display_old_price_amount_class', $old_price_amount_class, $id);
    $attributes = 'class="' . esc_attr($old_price_class) . '"';
    if (!$show_old_price) {
        $attributes .= ' style="display:none;"';
    }
    $old_price_before = sprintf($old_price_before, $attributes);
    $old_price_amount_before = sprintf($old_price_amount_before, esc_attr($old_price_amount_class), esc_attr($old_price_amount_id));
    $price_class = 'class="' . esc_attr(apply_filters('wpsc_the_product_price_display_price_class', esc_attr($price_class), $id)) . '"';
    $price_amount_class = apply_filters('wpsc_the_product_price_display_price_amount_class', esc_attr($price_amount_class), $id);
    $price_before = sprintf($price_before, $price_class);
    $price_amount_before = sprintf($price_amount_before, esc_attr($price_amount_class), esc_attr($price_amount_id));
    $you_save_class = apply_filters('wpsc_the_product_price_display_you_save_class', $you_save_class, $id);
    $you_save_amount_class = apply_filters('wpsc_the_product_price_display_you_save_amount_class', $you_save_amount_class, $id);
    $attributes = 'class="' . esc_attr($you_save_class) . '"';
    if (!$show_you_save) {
        $attributes .= ' style="display:none;"';
    }
    $you_save_before = sprintf($you_save_before, $attributes);
    $you_save_amount_before = sprintf($you_save_amount_before, esc_attr($you_save_amount_class), esc_attr($you_save_amount_id));
    $you_save = wpsc_currency_display($you_save);
    $old_price = $old_price_amount_before . $old_price . $old_price_amount_after;
    $current_price = $price_amount_before . $current_price . $price_amount_after;
    $you_save = $you_save_amount_before . $you_save . $you_save_amount_after;
    $old_price_text = sprintf($old_price_text, $old_price);
    $price_text = sprintf($price_text, $current_price);
    $you_save_text = sprintf($you_save_text, $you_save);
    if ($output_old_price) {
        echo $old_price_before . $old_price_text . $old_price_after . "\n";
    }
    if ($output_price) {
        echo $price_before . $price_text . $price_after . "\n";
    }
    if ($output_you_save) {
        echo $you_save_before . $you_save_text . $you_save_after . "\n";
    }
}
예제 #20
0
/**
 * Price Range Widget content function
 *
 * Displays a list of price ranges.
 *
 * @param $args (array) Arguments.
 */
function wpsc_price_range($args = null)
{
    global $wpdb;
    // Filter args not used at the moment, but this is here ready
    $args = wp_parse_args((array) $args, array());
    $product_page = get_option('product_list_url');
    $result = $wpdb->get_results("SELECT DISTINCT CAST(`meta_value` AS DECIMAL) AS `price` FROM " . $wpdb->postmeta . " AS `m` WHERE `meta_key` IN ('_wpsc_price') ORDER BY `price` ASC", ARRAY_A);
    if ($result != null) {
        sort($result);
        $count = count($result);
        $price_seperater = ceil($count / 6);
        for ($i = 0; $i < $count; $i += $price_seperater) {
            $ranges[] = round($result[$i]['price'], -1);
        }
        $ranges = array_unique($ranges);
        $final_count = count($ranges);
        $ranges = array_merge(array(), $ranges);
        $_SESSION['price_range'] = $ranges;
        echo '<ul>';
        for ($i = 0; $i < $final_count; $i++) {
            $j = $i;
            if ($i == $final_count - 1) {
                echo "<li><a href='" . esc_url(add_query_arg('range', $ranges[$i] . '-', $product_page)) . "'>" . esc_html_x('Over ', 'price range widget', 'wp-e-commerce') . wpsc_currency_display($ranges[$i]) . "</a></li>";
            } else {
                if ($ranges[$i] == 0) {
                    echo "<li><a href='" . esc_url(add_query_arg('range', '-' . ($ranges[$i + 1] - 1), $product_page)) . "'>" . esc_html_x('Under ', 'price range widget', 'wp-e-commerce') . wpsc_currency_display($ranges[$i + 1]) . "</a></li>";
                } else {
                    echo "<li><a href='" . esc_url(add_query_arg('range', $ranges[$i] . "-" . ($ranges[$i + 1] - 1), $product_page)) . "'>" . wpsc_currency_display($ranges[$i]) . " - " . wpsc_currency_display($ranges[$i + 1] - 1) . "</a></li>";
                }
            }
        }
        echo "<li><a href='" . esc_url(add_query_arg('range', 'all', get_option('product_list_url'))) . "'>" . _x('Show All', 'price range widget', 'wp-e-commerce') . "</a></li>";
        echo '</ul>';
    }
}
    public function filter_confirm_transaction_page()
    {
        ob_start();
        ?>
		<table width='400' class='paypal_express_form'>
	        <tr>
	            <td align='left' class='firstcol'><strong><?php 
        _e('Order Total:', 'wpsc');
        ?>
</strong></td>
	            <td align='left'><?php 
        echo wpsc_currency_display($this->purchase_log->get('totalprice'));
        ?>
</td>
	        </tr>
			<tr>
			    <td align='left' colspan='2'><strong><?php 
        _e('Shipping Details:', 'wpsc');
        ?>
</strong></td>
			</tr>
	        <tr>
	            <td align='left' class='firstcol'>
	                <?php 
        echo __('Address:', 'wpsc');
        ?>
				</td>
	            <td align='left'>
					<?php 
        echo esc_html($this->checkout_data->get('shippingaddress'));
        ?>
	            </td>
	        </tr>
	        <tr>
	            <td align='left' class='firstcol'>
	                <?php 
        echo __('City:', 'wpsc');
        ?>
				</td>
	            <td align='left'><?php 
        echo esc_html($this->checkout_data->get('shippingcity'));
        ?>
</td>
	        </tr>
	        <tr>
	            <td align='left' class='firstcol'>
	                <?php 
        echo __('State:', 'wpsc');
        ?>
				</td>
	            <td align='left'>
					<?php 
        echo esc_html(wpsc_get_region($this->checkout_data->get('shippingstate')));
        ?>
				</td>
	        </tr>
	        <tr>
	            <td align='left' class='firstcol'>
	                <?php 
        echo __('Postal code:', 'wpsc');
        ?>
				</td>
	            <td align='left'><?php 
        echo esc_html($this->checkout_data->get('shippingpostcode'));
        ?>
</td>
	        </tr>
	        <tr>
	            <td align='left' class='firstcol'>
	                <?php 
        echo __('Country:', 'wpsc');
        ?>
</td>
	            <td align='left'><?php 
        echo esc_html(wpsc_get_country($this->checkout_data->get('shippingcountry')));
        ?>
</td>
	        </tr>
	        <tr>
	            <td colspan='2'>
					<form action="<?php 
        echo remove_query_arg(array('payment_gateway', 'payment_gateway_callback'));
        ?>
" method='post'>
						<input type='hidden' name='payment_gateway' value='paypal-express-checkout' />
						<input type='hidden' name='payment_gateway_callback' value='process_confirmed_payment' />
						<p><input name='action' type='submit' value='<?php 
        _e('Confirm Payment', 'wpsc');
        ?>
' /></p>
					</form>
				</td>
	        </tr>
	    </table>
		<?php 
        $output = apply_filters('wpsc_confirm_payment_message', ob_get_clean(), $this->purchase_log);
        return $output;
    }
예제 #22
0
/**
 * wpsc the variation price function
 * @return string - the variation price
 */
function wpsc_the_variation_price($return_as_numeric = false)
{
    global $wpdb, $wpsc_variations;
    if ($wpsc_variations->variation_count > 0) {
        $product_id = get_the_ID();
        $wpq = array('variations' => $wpsc_variations->variation->slug, 'post_status' => 'inherit,publish', 'post_type' => 'wpsc-product', 'post_parent' => $product_id);
        $query = new WP_Query($wpq);
        // Should never happen
        if ($query->post_count != 1) {
            return false;
        }
        $variation_product_id = $query->posts[0]->ID;
        $price = get_product_meta($variation_product_id, "price", true);
        $special_price = get_product_meta($variation_product_id, "special_price", true);
        if ($special_price < $price && $special_price > 0) {
            $price = $special_price;
        }
        if (!$return_as_numeric) {
            $output = wpsc_currency_display($price, array('display_as_html' => false));
        } else {
            $output = $price;
        }
    } else {
        $output = false;
    }
    return $output;
}
예제 #23
0
    private function purchase_log_cart_items()
    {
        while (wpsc_have_purchaselog_details()) {
            wpsc_the_purchaselog_item();
            ?>
      <tr>
         <td><?php 
            echo wpsc_purchaselog_details_name();
            ?>
</td> <!-- NAME! -->
         <td><?php 
            echo wpsc_purchaselog_details_SKU();
            ?>
</td> <!-- SKU! -->
         <td><?php 
            echo wpsc_purchaselog_details_quantity();
            ?>
</td> <!-- QUANTITY! -->
         <td>
	    <?php 
            echo wpsc_currency_display(wpsc_purchaselog_details_price());
            do_action('wpsc_additional_sales_amount_info', wpsc_purchaselog_details_id());
            ?>
	 </td> <!-- PRICE! -->
         <td><?php 
            echo wpsc_currency_display(wpsc_purchaselog_details_shipping());
            ?>
</td> <!-- SHIPPING! -->
         <?php 
            if (wpec_display_product_tax()) {
                ?>
            <td><?php 
                echo wpsc_currency_display(wpsc_purchaselog_details_tax());
                ?>
</td> <!-- TAX! -->
         <?php 
            }
            ?>
         <!-- <td><?php 
            echo wpsc_currency_display(wpsc_purchaselog_details_discount());
            ?>
</td> --> <!-- DISCOUNT! -->
         <td class="amount"><?php 
            echo wpsc_currency_display(wpsc_purchaselog_details_total());
            ?>
</td> <!-- TOTAL! -->
      </tr>
      <?php 
        }
    }
예제 #24
0
파일: admin.php 프로젝트: hornet9/Morato
/**
 * wpsc_ajax_ie_save save changes made using inline edit
 *
 * @public
 *
 * @3.8
 * @returns nothing
 */
function wpsc_ajax_ie_save()
{
    $product_post_type = get_post_type_object('wpsc-product');
    if (!current_user_can($product_post_type->cap->edit_posts)) {
        echo '({"error":"' . __('Error: you don\'t have required permissions to edit this product', 'wpsc') . '", "id": "' . $_POST['id'] . '"})';
        die;
    }
    $product = array('ID' => $_POST['id'], 'post_title' => $_POST['title']);
    $id = wp_update_post($product);
    if ($id > 0) {
        //need parent meta to know which weight unit we are using
        $post = get_post($id);
        $parent_meta = get_product_meta($post->post_parent, 'product_metadata', true);
        $product_meta = get_product_meta($product['ID'], 'product_metadata', true);
        if (is_numeric($_POST['weight']) || empty($_POST['weight'])) {
            $product_meta['weight'] = wpsc_convert_weight($_POST['weight'], $parent_meta['weight_unit'], 'pound', true);
            $product_meta['weight_unit'] = $parent_meta['weight_unit'];
        }
        update_product_meta($product['ID'], 'product_metadata', $product_meta);
        update_product_meta($product['ID'], 'price', (double) $_POST['price']);
        update_product_meta($product['ID'], 'special_price', (double) $_POST['special_price']);
        update_product_meta($product['ID'], 'sku', $_POST['sku']);
        if (!is_numeric($_POST['stock'])) {
            update_product_meta($product['ID'], 'stock', '');
        } else {
            update_product_meta($product['ID'], 'stock', absint($_POST['stock']));
        }
        $post = get_post($id);
        $meta = get_product_meta($id, 'product_metadata', true);
        $price = get_product_meta($id, 'price', true);
        $special_price = get_product_meta($id, 'special_price', true);
        $sku = get_product_meta($id, 'sku', true);
        $sku = $sku ? $sku : __('N/A', 'wpsc');
        $stock = get_product_meta($id, 'stock', true);
        $stock = $stock === '' ? __('N/A', 'wpsc') : $stock;
        $results = array('id' => $id, 'title' => $post->post_title, 'weight' => wpsc_convert_weight($meta['weight'], 'pound', $parent_meta['weight_unit']), 'price' => wpsc_currency_display($price), 'special_price' => wpsc_currency_display($special_price), 'sku' => $sku, 'stock' => $stock);
        echo '(' . json_encode($results) . ')';
        die;
    } else {
        echo '({"error":"' . __('Error updating product', 'wpsc') . '", "id": "' . $_POST['id'] . '"})';
    }
    die;
}
예제 #25
0
function wpsc_packing_slip($purchase_id)
{
    echo "<!DOCTYPE html><html><head><title>" . __('Packing Slip', 'wpsc') . "</title></head><body id='wpsc-packing-slip'>";
    global $wpdb;
    $purch_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`='" . $purchase_id . "'";
    $purch_data = $wpdb->get_row($purch_sql, ARRAY_A);
    //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
    $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase_id . "";
    $cart_log = $wpdb->get_results($cartsql, ARRAY_A);
    $j = 0;
    if ($cart_log != null) {
        echo "<div class='packing_slip'>\n\r";
        echo apply_filters('wpsc_packing_slip_header', '<h2>' . __('Packing Slip', 'wpsc') . "</h2>\n\r");
        echo "<strong>" . __('Order', 'wpsc') . " #</strong> " . $purchase_id . "<br /><br />\n\r";
        echo "<table>\n\r";
        $form_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE\t`log_id` = '" . (int) $purchase_id . "'";
        $input_data = $wpdb->get_results($form_sql, ARRAY_A);
        foreach ($input_data as $input_row) {
            $rekeyed_input[$input_row['form_id']] = $input_row;
        }
        if ($input_data != null) {
            $form_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1'", ARRAY_A);
            foreach ($form_data as $form_field) {
                switch ($form_field['type']) {
                    case 'country':
                        $delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('" . $wpdb->escape($purch_data['billing_country']) . "')");
                        if (is_numeric($purch_data['billing_region']) && $delivery_region_count > 0) {
                            echo "\t<tr><td>" . __('State', 'wpsc') . ":</td><td>" . wpsc_get_region($purch_data['billing_region']) . "</td></tr>\n\r";
                        }
                        echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                        break;
                    case 'delivery_country':
                        if (is_numeric($purch_data['shipping_region']) && $delivery_region_count > 0) {
                            echo "\t<tr><td>" . __('State', 'wpsc') . ":</td><td>" . wpsc_get_region($purch_data['shipping_region']) . "</td></tr>\n\r";
                        }
                        echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                        break;
                    case 'heading':
                        if ($form_field['name'] == "Hidden Fields") {
                            continue;
                        } else {
                            echo "\t<tr class='heading'><td colspan='2'><strong>" . wp_kses($form_field['name'], array()) . ":</strong></td></tr>\n\r";
                        }
                        break;
                    default:
                        if ($form_field['name'] == "Cupcakes") {
                            parse_str($rekeyed_input[$form_field['id']]['value'], $cupcakes);
                            foreach ($cupcakes as $product_id => $quantity) {
                                $product = get_post($product_id);
                                $string .= "(" . $quantity . ") " . $product->post_title . ", ";
                            }
                            $string = rtrim($string, ", ");
                            echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($string), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                        } else {
                            if ($form_field['name'] == "State" && !empty($purch_data['billing_region']) || $form_field['name'] == "State" && !empty($purch_data['billing_region'])) {
                                echo "";
                            } else {
                                echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                            }
                        }
                        break;
                }
            }
        } else {
            echo "\t<tr><td>" . __('Name', 'wpsc') . ":</td><td>" . $purch_data['firstname'] . " " . $purch_data['lastname'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . __('Address', 'wpsc') . ":</td><td>" . $purch_data['address'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . __('Phone', 'wpsc') . ":</td><td>" . $purch_data['phone'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . __('Email', 'wpsc') . ":</td><td>" . $purch_data['email'] . "</td></tr>\n\r";
        }
        if (2 == get_option('payment_method')) {
            $gateway_name = '';
            $nzshpcrt_gateways = nzshpcrt_get_gateways();
            foreach ($nzshpcrt_gateways as $gateway) {
                if ($purch_data['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purch_data['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = __('Manual Payment', 'wpsc');
                }
            }
        }
        echo "</table>\n\r";
        do_action('wpsc_packing_slip_extra_info', $purchase_id);
        echo "<table class='packing_slip'>";
        echo "<tr>";
        echo " <th>" . __('Quantity', 'wpsc') . " </th>";
        echo " <th>" . __('Name', 'wpsc') . "</th>";
        echo " <th>" . __('Price', 'wpsc') . " </th>";
        echo " <th>" . __('Shipping', 'wpsc') . " </th>";
        echo '<th>' . __('Tax', 'wpsc') . '</th>';
        echo '</tr>';
        $endtotal = 0;
        $all_donations = true;
        $all_no_shipping = true;
        $file_link_list = array();
        foreach ($cart_log as $cart_row) {
            $alternate = "";
            $j++;
            if ($j % 2 != 0) {
                $alternate = "class='alt'";
            }
            // product ID will be $cart_row['prodid']. need to fetch name and stuff
            $variation_list = '';
            if ($cart_row['donation'] != 1) {
                $all_donations = false;
            }
            if ($cart_row['no_shipping'] != 1) {
                $shipping = $cart_row['pnp'] * $cart_row['quantity'];
                $total_shipping += $shipping;
                $all_no_shipping = false;
            } else {
                $shipping = 0;
            }
            $price = $cart_row['price'] * $cart_row['quantity'];
            $gst = $price - $price / (1 + $cart_row['gst'] / 100);
            if ($gst > 0) {
                $tax_per_item = $gst / $cart_row['quantity'];
            }
            echo "<tr {$alternate}>";
            echo " <td>";
            echo $cart_row['quantity'];
            echo " </td>";
            echo " <td>";
            echo $cart_row['name'];
            echo stripslashes($variation_list);
            echo " </td>";
            echo " <td>";
            echo wpsc_currency_display($price);
            echo " </td>";
            echo " <td>";
            echo wpsc_currency_display($shipping);
            echo " </td>";
            echo '<td>';
            echo wpsc_currency_display($cart_row['tax_charged']);
            echo '</td>';
            echo '</tr>';
        }
        echo "</table>";
        echo '<table class="packing-slip-totals">';
        echo '<tr><th>Base Shipping</th><td>' . wpsc_currency_display($purch_data['base_shipping']) . '</td></tr>';
        echo '<tr><th>Total Shipping</th><td>' . wpsc_currency_display($purch_data['base_shipping'] + $total_shipping) . '</td></tr>';
        //wpec_taxes
        if ($purch_data['wpec_taxes_total'] != 0.0) {
            echo '<tr><th>Taxes</th><td>' . wpsc_currency_display($purch_data['wpec_taxes_total']) . '</td></tr>';
        }
        echo '<tr><th>Total Price</th><td>' . wpsc_currency_display($purch_data['totalprice']) . '</td></tr>';
        echo '</table>';
        echo "</div>\n\r";
    } else {
        echo "<br />" . __('This users cart was empty', 'wpsc');
    }
}
예제 #26
0
 /**
  * Refund a payment
  *
  * @param  string $capture_id
  * @param  float  $amount
  * @param  string $note
  */
 public function refund_payment($capture_id, $amount, $note)
 {
     if ($this->log->get('gateway') == 'amazon-payments') {
         if ($this->doing_ipn) {
             return;
         }
         $base_country = new WPSC_Country(wpsc_get_base_country());
         if ('US' == $base_country->get_isocode() && $amount > $this->log->get('totalprice')) {
             $this->log->set('amazon-status', __('Unable to refund funds via amazon:', 'wpsc') . ' ' . __('Refund amount is greater than order total.', 'wpsc'))->save();
             return;
         } elseif ($amount > min($this->log->get('totalprice') * 1.15, $this->log->get('totalprice') + 75)) {
             $this->log->set('amazon-status', __('Unable to refund funds via amazon:', 'wpsc') . ' ' . __('Refund amount is greater than the max refund amount.', 'wpsc'))->save();
             return;
         }
         $response = $this->gateway->api_request(array('Action' => 'Refund', 'AmazonCaptureId' => $capture_id, 'RefundReferenceId' => $this->log->get('id') . '-' . current_time('timestamp', true), 'RefundAmount.Amount' => $amount, 'RefundAmount.CurrencyCode' => strtoupper($this->gateway->get_currency_code()), 'SellerRefundNote' => $note));
         if (is_wp_error($response)) {
             $this->log->set('amazon-status', __('Unable to refund funds via amazon:', 'wpsc') . ' ' . $response->get_error_message())->save();
         } elseif (isset($response['Error']['Message'])) {
             $this->log->set('amazon-status', $response['Error']['Message'])->save();
         } else {
             $refund_id = $response['RefundResult']['RefundDetails']['AmazonRefundId'];
             $this->log->set('amazon-status', sprintf(__('Refunded %s (%s)', 'wpsc'), wpsc_currency_display($amount), $note))->save();
             $this->log->set('processed', WPSC_Purchase_Log::REFUNDED)->save();
             wpsc_add_purchase_meta($this->log->get('id'), 'amazon_refund_id', $refund_id);
         }
     }
 }
예제 #27
0
/**
 * nzshpcrt_currency_display function.
 * Obsolete, preserved for backwards compatibility
 *
 * @access public
 * @param mixed $price_in
 * @param mixed $tax_status
 * @param bool $nohtml deprecated 
 * @param bool $id. deprecated
 * @param bool $no_dollar_sign. (default: false)
 * @return void
 */
function nzshpcrt_currency_display($price_in, $tax_status, $nohtml = false, $id = false, $no_dollar_sign = false)
{
    //_deprecated_function( __FUNCTION__, '3.8', 'wpsc_currency_display' );
    $output = wpsc_currency_display($price_in, array('display_currency_symbol' => !(bool) $no_dollar_sign, 'display_as_html' => (bool) $nohtml, 'display_decimal_point' => true, 'display_currency_code' => false));
    return $output;
}
예제 #28
0
/**
 * Displays products that were bought along with the product defined by $product_id.
 * This functionality will be deprecated and be provided by a plugin in a future version.
 */
function wpsc_also_bought($product_id)
{
    global $wpdb;
    if (get_option('wpsc_also_bought') == 0) {
        return '';
    }
    // To be made customiseable in a future release
    $also_bought_limit = 3;
    $element_widths = 96;
    $image_display_height = 96;
    $image_display_width = 96;
    // Filter will be used by a plugin to provide 'Also Bought' functionality when this is deprecated from core.
    // Filter is currently private and should not be used by plugin/theme devs as it may only be temporary.
    $output = apply_filters('_wpsc_also_bought', '', $product_id);
    if (!empty($output)) {
        return $output;
    }
    // If above filter returns output then the following is ignore and can be deprecated in future.
    $also_bought = $wpdb->get_results($wpdb->prepare("SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`= %d AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT {$also_bought_limit}", $product_id), ARRAY_A);
    if (is_array($also_bought) && count($also_bought) > 0) {
        $output .= '<h2 class="prodtitles wpsc_also_bought">' . __('People who bought this item also bought', 'wpsc') . '</h2>';
        $output .= '<div class="wpsc_also_bought">';
        foreach ($also_bought as $also_bought_data) {
            $output .= '<div class="wpsc_also_bought_item" style="width: ' . $element_widths . 'px;">';
            if (get_option('show_thumbnails') == 1) {
                $image_path = wpsc_the_product_thumbnail($image_display_width, $image_display_height, $also_bought_data['ID']);
                if ($image_path) {
                    $output .= '<a href="' . esc_attr(get_permalink($also_bought_data['ID'])) . '" class="preview_link" rel="' . esc_attr(sanitize_html_class(get_the_title($also_bought_data['ID']))) . '">';
                    $output .= '<img src="' . esc_attr($image_path) . '" id="product_image_' . $also_bought_data['ID'] . '" class="product_image" />';
                    $output .= '</a>';
                } else {
                    if (get_option('product_image_width') != '') {
                        $width_and_height = 'width="' . $image_display_height . '" height="' . $image_display_height . '" ';
                    } else {
                        $width_and_height = '';
                    }
                    $output .= '<img src="' . WPSC_CORE_THEME_URL . '/wpsc-images/noimage.png" title="' . esc_attr(get_the_title($also_bought_data['ID'])) . '" alt="' . esc_attr(get_the_title($also_bought_data['ID'])) . '" id="product_image_' . $also_bought_data['ID'] . '" class="product_image" ' . $width_and_height . '/>';
                }
            }
            $output .= '<a class="wpsc_product_name" href="' . get_permalink($also_bought_data['ID']) . '">' . get_the_title($also_bought_data['ID']) . '</a>';
            if (!wpsc_product_is_donation($also_bought_data['ID'])) {
                // Ideally use the wpsc_the_product_price_display() function here but needs some tweaking
                $price = get_product_meta($also_bought_data['ID'], 'price', true);
                $special_price = get_product_meta($also_bought_data['ID'], 'special_price', true);
                if (!empty($special_price)) {
                    $output .= '<span style="text-decoration: line-through;">' . wpsc_currency_display($price) . '</span>';
                    $output .= wpsc_currency_display($special_price);
                } else {
                    $output .= wpsc_currency_display($price);
                }
            }
            $output .= '</div>';
        }
        $output .= '</div>';
        $output .= '<br clear="all" />';
    }
    return $output;
}
예제 #29
0
function wpsc_display_purchlog_totalprice()
{
    global $purchlogitem;
    $total = $purchlogitem->totalAmount - wpsc_display_purchlog_discount(true) + wpsc_display_purchlog_shipping(true) + wpsc_display_purchlog_taxes(true);
    return wpsc_currency_display($total, array('display_as_html' => false));
}
 public function column_amount($item)
 {
     echo '<a href="' . esc_attr($this->item_url($item)) . '" title="' . esc_attr__('View order details', 'wpsc') . '">';
     echo wpsc_currency_display($item->amount) . "<br />";
     echo '<small>' . sprintf(_n('1 item', '%s items', $item->item_count, 'wpsc'), number_format_i18n($item->item_count)) . '</small>';
     echo '</a>';
 }