コード例 #1
0
ファイル: checkout.class.php プロジェクト: ashik968/digiplot
/**
 * returns the tax label
 * @access public
 *
 * @since 3.7
 * @param $checkout (unused)
 * @return string Tax Included or Tax
 */
function wpsc_display_tax_label($checkout = false)
{
    global $wpsc_cart;
    if (wpsc_tax_isincluded()) {
        return __('Tax Included', 'wp-e-commerce');
    } else {
        return __('Tax', 'wp-e-commerce');
    }
}
コード例 #2
0
function wpsc_display_tax_label($checkout = false)
{
    global $wpsc_cart;
    if (wpsc_tax_isincluded()) {
        if ($checkout) {
            return sprintf(__('Tax Included (%s%%)', 'wpsc'), $wpsc_cart->tax_percentage);
        } else {
            return __('Tax Included', 'wpsc');
        }
    } else {
        return __('Tax', 'wpsc');
    }
}
コード例 #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
 /**
  * construct value array method, converts the data gathered by the base class code to something acceptable to the gateway
  * @access public
  */
 function construct_value_array()
 {
     //$collected_gateway_data
     $paypal_vars = array();
     // Store settings to be sent to paypal
     $data = array();
     $data['USER'] = get_option('paypal_pro_username');
     $data['PWD'] = get_option('paypal_pro_password');
     $data['SIGNATURE'] = get_option('paypal_pro_signature');
     $data['VERSION'] = "52.0";
     $data['METHOD'] = "DoDirectPayment";
     $data['PAYMENTACTION'] = "Sale";
     $data['RETURNFMFDETAILS'] = "1";
     // optional - return fraud management filter data
     $data['CURRENCYCODE'] = $this->get_paypal_currency_code();
     // Basic Cart Data
     $data['INVNUM'] = $this->cart_data['session_id'];
     $data['NOTIFYURL'] = add_query_arg('gateway', 'wpsc_merchant_paypal_pro', $this->cart_data['notification_url']);
     $data['IPADDRESS'] = $_SERVER["REMOTE_ADDR"];
     if ($this->cart_data['billing_address']['country'] == 'UK') {
         $this->cart_data['billing_address']['country'] = 'GB';
     }
     // Billing Data
     $data['FIRSTNAME'] = $this->cart_data['billing_address']['first_name'];
     $data['LASTNAME'] = $this->cart_data['billing_address']['last_name'];
     $data['EMAIL'] = $this->cart_data['email_address'];
     $data['STREET'] = $this->cart_data['billing_address']['address'];
     $data['CITY'] = $this->cart_data['billing_address']['city'];
     $data['STATE'] = $this->cart_data['billing_address']['state'];
     $data['COUNTRYCODE'] = $this->cart_data['billing_address']['country'];
     $data['ZIP'] = $this->cart_data['billing_address']['post_code'];
     // Shipping Data
     $data['SHIPTONAME'] = $this->cart_data['shipping_address']['first_name'] . " " . $this->cart_data['shipping_address']['last_name'];
     $data['SHIPTOSTREET'] = $this->cart_data['shipping_address']['address'];
     $data['SHIPTOCITY'] = $this->cart_data['shipping_address']['city'];
     // Check the state for internal numeric ID and trap it
     if (is_numeric($this->cart_data['shipping_address']['state'])) {
         $this->cart_data['shipping_address']['state'] = wpsc_get_state_by_id($this->cart_data['shipping_address']['state'], 'code');
     }
     if ($this->cart_data['shipping_address']['country'] == 'UK') {
         $this->cart_data['shipping_address']['country'] = 'GB';
     }
     $data['SHIPTOSTATE'] = $this->cart_data['shipping_address']['state'];
     $data['SHIPTOCOUNTRY'] = $this->cart_data['shipping_address']['country'];
     $data['SHIPTOZIP'] = $this->cart_data['shipping_address']['post_code'];
     // Credit Card Data
     $data['CREDITCARDTYPE'] = $_POST['cctype'];
     $data['ACCT'] = str_replace(array(' ', '-'), '', $_POST['card_number']);
     $data['EXPDATE'] = $_POST['expiry']['month'] . $_POST['expiry']['year'];
     $data['CVV2'] = $_POST['card_code'];
     // Ordered Items
     // Cart Item Data
     $i = $item_total = 0;
     $tax_total = wpsc_tax_isincluded() ? 0 : $this->cart_data['cart_tax'];
     $shipping_total = $this->convert($this->cart_data['base_shipping']);
     foreach ($this->cart_items as $cart_row) {
         $data['L_NAME' . $i] = apply_filters('the_title', $cart_row['name']);
         $data['L_AMT' . $i] = $this->convert($cart_row['price']);
         $data['L_NUMBER' . $i] = $i;
         $data['L_QTY' . $i] = $cart_row['quantity'];
         $shipping_total += $this->convert($cart_row['shipping']);
         $item_total += $this->convert($cart_row['price']) * $cart_row['quantity'];
         $i++;
     }
     if ($this->cart_data['has_discounts']) {
         $discount_value = $this->convert($this->cart_data['cart_discount_value']);
         $coupon = new wpsc_coupons($this->cart_data['cart_discount_data']);
         // free shipping
         if ($coupon->is_percentage == 2) {
             $shipping_total = 0;
             $discount_value = 0;
         } elseif ($discount_value >= $item_total) {
             $discount_value = $item_total - 0.01;
             $shipping_total -= 0.01;
         }
         $data["L_NAME{$i}"] = _x('Coupon / Discount', 'PayPal Pro Item Name for Discounts', 'wpsc');
         $data["L_AMT{$i}"] = -$discount_value;
         $data["L_NUMBER{$i}"] = $i;
         $data["L_QTY{$i}"] = 1;
         $item_total -= $discount_value;
     }
     // Cart totals
     $data['ITEMAMT'] = $this->format_price($item_total);
     $data['SHIPPINGAMT'] = $this->format_price($shipping_total);
     $data['TAXAMT'] = $this->convert($tax_total);
     $data['AMT'] = $data['ITEMAMT'] + $data['SHIPPINGAMT'] + $data['TAXAMT'];
     $this->collected_gateway_data = apply_filters('wpsc_paypal_pro_gateway_data_array', $data, $this->cart_items);
 }
コード例 #5
0
ファイル: cart.class.php プロジェクト: dreamteam111/dreamteam
 /**
  * Calculate total price method
  *
  * @access public
  *
  * @return float returns the price as a floating point value
  */
 function calculate_total_price()
 {
     // Calculate individual component that comprise the cart total
     $subtotal = $this->calculate_subtotal();
     $shipping = $this->calculate_total_shipping();
     // Get tax only if it is included
     $tax = !wpsc_tax_isincluded() ? $this->calculate_total_tax() : 0.0;
     // Get coupon amount, note that no matter what float precision this
     // coupon amount is, it's always saved to the database with rounded
     // value anyways
     $coupons_amount = round($this->coupons_amount, 2);
     // Calculate the total
     $total = $subtotal > $coupons_amount ? $subtotal - $coupons_amount + $shipping + $tax : $tax + $shipping;
     // Filter total
     $total = apply_filters('wpsc_calculate_total_price', $total, $subtotal, $shipping, $tax, $coupons_amount, $this);
     // Set variable and return
     $this->total_price = $total;
     return $total;
 }
コード例 #6
0
 function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL)
 {
     global $wpdb;
     $nvpstr = '';
     $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
     $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
     $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
     $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
     $data = array();
     if (!isset($this->cart_data['shipping_address']['first_name']) && !isset($this->cart_data['shipping_address']['last_name'])) {
         $this->cart_data['shipping_address']['first_name'] = $this->cart_data['billing_address']['first_name'];
         $this->cart_data['shipping_address']['last_name'] = $this->cart_data['billing_address']['last_name'];
     }
     if ($this->cart_data['shipping_address']['country'] == 'UK') {
         $this->cart_data['shipping_address']['country'] = 'GB';
     }
     $data += array('PAYMENTREQUEST_0_SHIPTONAME' => $this->cart_data['shipping_address']['first_name'] . ' ' . $this->cart_data['shipping_address']['last_name'], 'PAYMENTREQUEST_0_SHIPTOSTREET' => $this->cart_data['shipping_address']['address'], 'PAYMENTREQUEST_0_SHIPTOCITY' => $this->cart_data['shipping_address']['city'], 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => $this->cart_data['shipping_address']['country'], 'PAYMENTREQUEST_0_SHIPTOZIP' => $this->cart_data['shipping_address']['post_code']);
     if (!empty($this->cart_data['shipping_address']['state'])) {
         $data += array('PAYMENTREQUEST_0_SHIPTOSTATE' => $this->cart_data['shipping_address']['state']);
     }
     $i = 0;
     $item_total = 0;
     $tax_total = 0;
     $shipping_total = 0;
     $is_free_shipping = false;
     if ($this->cart_data['has_discounts'] && (double) $this->cart_data['cart_discount_value'] > 0) {
         $coupon = new wpsc_coupons($this->cart_data['cart_discount_coupon']);
         $is_free_shipping = $coupon->is_free_shipping();
     }
     foreach ($this->cart_items as $cart_item) {
         $data["L_PAYMENTREQUEST_0_NAME{$i}"] = urlencode(apply_filters('the_title', $cart_item['name']));
         $data["L_PAYMENTREQUEST_0_AMT{$i}"] = $this->convert($cart_item['price']);
         $data["L_PAYMENTREQUEST_0_NUMBER{$i}"] = $i;
         $data["L_PAYMENTREQUEST_0_QTY{$i}"] = $cart_item['quantity'];
         $item_total += $this->convert($cart_item['price']) * $cart_item['quantity'];
         $shipping_total += $cart_item['shipping'];
         $i++;
     }
     //if we have a discount then include a negative amount with that discount
     // in php 0.00 = true so we will change that here
     if ($this->cart_data['cart_discount_value'] == 0.0) {
         $this->cart_data['cart_discount_value'] = 0;
     }
     $discount_value = $this->convert($this->cart_data['cart_discount_value']);
     if ($this->cart_data['cart_discount_value'] && !$is_free_shipping) {
         // if item total < discount amount, leave at least 0.01 unit in item total, then subtract
         // 0.01 from shipping as well
         if (!$is_free_shipping && $discount_value >= $item_total) {
             $discount_value = $item_total - 0.01;
             $shipping_total -= 0.01;
         }
         $item_total -= $discount_value;
         $data["L_PAYMENTREQUEST_0_NAME{$i}"] = "Discount / Coupon";
         $data["L_PAYMENTREQUEST_0_AMT{$i}"] = -$discount_value;
         $data["L_PAYMENTREQUEST_0_NUMBER{$i}"] = $i;
         $data["L_PAYMENTREQUEST_0_QTY{$i}"] = 1;
     }
     $data["PAYMENTREQUEST_0_ITEMAMT"] = $this->format_price($item_total);
     if ($discount_value && $is_free_shipping) {
         $data["PAYMENTREQUEST_0_SHIPPINGAMT"] = 0;
     } else {
         $data["PAYMENTREQUEST_0_SHIPPINGAMT"] = $this->convert($this->cart_data['base_shipping'] + $shipping_total);
     }
     $total = $data["PAYMENTREQUEST_0_ITEMAMT"] + $data["PAYMENTREQUEST_0_SHIPPINGAMT"];
     if (!wpsc_tax_isincluded()) {
         $data["PAYMENTREQUEST_0_TAXAMT"] = $this->convert($this->cart_data['cart_tax']);
         $total += $data["PAYMENTREQUEST_0_TAXAMT"];
     }
     // adjust total amount in case we had to round up after converting currency
     // or discount calculation
     if ($total != $paymentAmount) {
         $paymentAmount = $total;
     }
     $data["PAYMENTREQUEST_0_AMT"] = $paymentAmount;
     if (count($data) >= 4) {
         $temp_data = array();
         foreach ($data as $key => $value) {
             $temp_data[] = $key . "=" . $value;
         }
         $nvpstr = $nvpstr . "&" . implode("&", $temp_data);
     }
     wpsc_update_customer_meta('paypal_express_currency_code_type', $currencyCodeType);
     wpsc_update_customer_meta('paypal_express_payment_type', $paymentType);
     $resArray = paypal_hash_call("SetExpressCheckout", $nvpstr);
     $ack = strtoupper($resArray["ACK"]);
     if ($ack == "SUCCESS") {
         $token = urldecode($resArray["TOKEN"]);
         wpsc_update_customer_meta('paypal_express_token', $token);
     }
     return $resArray;
 }
コード例 #7
0
function wpsc_display_sales_log_index()
{
    ?>
	<div class="wrap">
		<?php 
    //screen_icon();
    ?>
		<h2><?php 
    echo wp_specialchars(__('Sales', 'wpsc'));
    ?>
 </h2>
		<?php 
    //START OF PURCHASE LOG DEFAULT VIEW
    ?>
		<?php 
    if (isset($_GET['view_purchlogs_by']) || isset($_GET['view_purchlogs_by_status'])) {
        wpsc_change_purchlog_view($_GET['view_purchlogs_by'], $_GET['view_purchlogs_by_status']);
    }
    if (!isset($_REQUEST['purchaselog_id'])) {
        $columns = array('cb' => '<input type="checkbox" />', 'date' => 'Date', 'name' => '', 'amount' => 'Amount', 'details' => 'Details', 'status' => 'Status', 'delete' => 'Delete', 'track' => 'Track');
        register_column_headers('display-sales-list', $columns);
        ///// start of update message section //////
        //$fixpage = get_option('siteurl').'/wp-admin/admin.php?page='.WPSC_FOLDER.'/wpsc-admin/purchlogs_upgrade.php';
        $current_user = wp_get_current_user();
        // we put the closed postboxes array into the product data to propagate it to each form without having it global.
        $dashboard_data['closed_postboxes'] = (array) get_usermeta($current_user->ID, 'closedpostboxes_store_page_wpscsalelogs');
        //			  exit('<pre>'.print_r($dashboard_data,true).'</pre>');
        //			  $dashboard_data['hidden_postboxes'] = (array)get_usermeta( $current_user->ID, 'metaboxhidden_store_page_wpsc-edit-products');
        $fixpage = get_option('siteurl') . '/wp-admin/admin.php?page=wpsc-sales-logs&amp;subpage=upgrade-purchase-logs';
        if (isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['locked'])) {
            ?>
			<div id="message" class="updated fade"><p>
			<?php 
            if (isset($_GET['updated']) && (int) $_GET['updated']) {
                printf(__ngettext('%s Purchase Log updated.', '%s Purchase Logs updated.', $_GET['updated']), number_format_i18n($_GET['updated']));
                unset($_GET['updated']);
            }
            if (isset($_GET['skipped']) && (int) $_GET['skipped']) {
                unset($_GET['skipped']);
            }
            if (isset($_GET['locked']) && (int) $_GET['locked']) {
                printf(__ngettext('%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $_GET['locked']), number_format_i18n($_GET['locked']));
                unset($_GET['locked']);
            }
            if (isset($_GET['deleted']) && (int) $_GET['deleted']) {
                printf(__ngettext('%s Purchase Log deleted.', '%s Purchase Logs deleted.', $_GET['deleted']), number_format_i18n($_GET['deleted']));
                unset($_GET['deleted']);
            }
            //$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted','wpsc_downloadcsv','rss_key','start_timestamp','end_timestamp','email_buyer_id'), $_SERVER['REQUEST_URI'] );
            ?>
			</p></div>
		<?php 
        }
        if (get_option('wpsc_purchaselogs_fixed') == false || wpsc_check_uniquenames()) {
            ?>
				<div class='error' style='padding:8px;line-spacing:8px;'><span ><?php 
            _e('When upgrading the WP e-Commerce Plugin from 3.6.* to 3.7 it is required that you associate your Checkout form fields with the new Purchase Logs system. To do so please.');
            ?>
 <a href='<?php 
            echo $fixpage;
            ?>
'>Click Here</a></span></div>
	<?php 
        }
        ///// end of update message section //////
        ?>
		
		
		
		<div id='dashboard-widgets' style='min-width: 825px;'>
			<!--
 <div class='inner-sidebar'> 
					<div class='meta-box-sortables'>			
						<?php 
        //if(IS_WP27){
        //	display_ecomm_rss_feed();
        //}
        ?>
					</div>
			</div>
-->
			<?php 
        /* end of sidebar start of main column */
        ?>
			<div id='post-body' class='has-sidebar metabox-holder' style='width:95%;'>
				<div id='dashboard-widgets-main-content-wpsc' class='has-sidebar-content'>
					<?php 
        if (function_exists('fetch_feed')) {
            ?>
					<div class='postbox <?php 
            echo array_search('wpsc_getshopped_news', $dashboard_data['closed_postboxes']) !== false ? 'closed' : '';
            ?>
' id="wpsc_getshopped_news">	 
						<h3 class='hndle'>
							<span><?php 
            _e('GetShopped News', 'wpsc');
            ?>
</span>
							<br class='clear'/>
						</h3>
		
						<div class='inside'>
							<?php 
            //			exit('Data:<pre>'.print_r($dashboard_data,true).'</pre>');
            $rss = fetch_feed('http://getshopped.org/category/wp-e-commerce-plugin/');
            $args = array('show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items' => 3);
            wp_widget_rss_output($rss, $args);
            ?>
						</div>
					</div>
					<?php 
        }
        //	add_meta_box("wpsc_getshopped_news", __('GetShopped News', 'wpsc'), "wpsc_getshopped_news_meta_box", "wpsc");
        //	do_meta_boxes('wpsc','advanced',null);
        if (function_exists('wpsc_right_now')) {
            echo wpsc_right_now($dashboard_data['closed_postboxes']);
        }
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
 
			   	</div><br />
			   	<div id='wpsc_purchlog_searchbox'>
			   		<?php 
        wpsc_purchaselogs_searchbox();
        ?>
			   	</div><br />
			   		<?php 
        wpsc_purchaselogs_displaylist();
        ?>
 				
				
			</div>
		</div>
		<?php 
    } else {
        //NOT IN GENERIC PURCHASE LOG PAGE, IN DETAILS PAGE PER PURCHASE LOG
        if (isset($_GET['cleared']) || isset($_GET['cleared'])) {
            ?>
			<div id="message" class="updated fade"><p>
			<?php 
            if (isset($_GET['cleared']) && $_GET['cleared'] == true) {
                printf(__ngettext('Downloads for this log have been released.', 'Downloads for this log have been released.', $_GET['cleared']), $_GET['cleared']);
                unset($_GET['cleared']);
            }
            if (isset($_GET['sent']) && (int) $_GET['sent']) {
                printf(__ngettext('Receipt has been resent ', 'Receipt has been resent ', $_GET['sent']), $_GET['sent']);
                unset($_GET['sent']);
            }
            ?>
 </p></div>
			<?php 
        }
        //$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted','cleared'), $_SERVER['REQUEST_URI'] );
        ?>

			
			<?php 
        $page_back = remove_query_arg(array('locked', 'skipped', 'updated', 'deleted', 'purchaselog_id'), $_SERVER['REQUEST_URI']);
        if (wpsc_tax_isincluded() == false) {
            $taxlabel = 'Tax';
        } else {
            $taxlabel = 'Tax Included';
        }
        $columns = array('title' => 'Name', 'sku' => 'SKU', 'quantity' => 'Quantity', 'price' => 'Price', 'shipping' => 'Shipping', 'tax' => $taxlabel, 'total' => 'Total');
        register_column_headers('display-purchaselog-details', $columns);
        ?>
			<div id='post-body' class='has-sidebar' style='width:95%;'>
				<?php 
        if (wpsc_has_purchlog_shipping()) {
            ?>
				<div id='wpsc_shipping_details_box'>	
					<h3><?php 
            _e('Shipping Details');
            ?>
</h3>
					<p><strong><?php 
            echo wpsc_display_purchlog_shipping_name();
            ?>
</strong></p>
					<p>
					<?php 
            echo wpsc_display_purchlog_shipping_address();
            ?>
<br />
					<?php 
            echo wpsc_display_purchlog_shipping_city();
            ?>
<br />
					<?php 
            echo wpsc_display_purchlog_shipping_state_and_postcode();
            ?>
<br />
					<?php 
            echo wpsc_display_purchlog_shipping_country();
            ?>
<br />
					</p>
					<strong><?php 
            _e('Shipping Options');
            ?>
</strong>
					<p>
					
					<?php 
            _e('Shipping Method:');
            ?>
 <?php 
            echo wpsc_display_purchlog_shipping_method();
            ?>
<br />
					<?php 
            _e('Shipping Option:');
            ?>
 <?php 
            echo wpsc_display_purchlog_shipping_option();
            ?>
<br />
					<?php 
            if (wpsc_purchlogs_has_tracking()) {
                ?>
						<?php 
                _e('Tracking ID:');
                ?>
 <?php 
                echo wpsc_purchlogitem_trackid();
                ?>
<br />
						<?php 
                _e('Shipping Status:');
                ?>
 <?php 
                echo wpsc_purchlogitem_trackstatus();
                ?>
<br />
						<?php 
                _e('Track History:');
                ?>
 <?php 
                echo wpsc_purchlogitem_trackhistory();
                ?>
					<?php 
            }
            ?>
					</p>
				</div>
				<?php 
        }
        ?>
				<div id='wpsc_billing_details_box'>
					<h3><?php 
        _e('Billing Details');
        ?>
</h3>
					<p><strong><?php 
        _e('Purchase Log Date:');
        ?>
 </strong><?php 
        echo wpsc_purchaselog_details_date();
        ?>
 </p>
					<p><strong><?php 
        _e('Purchase Number:');
        ?>
 </strong><?php 
        echo wpsc_purchaselog_details_purchnumber();
        ?>
 </p>
					<p><strong><?php 
        _e('Buyers Name:');
        ?>
 </strong><?php 
        echo wpsc_display_purchlog_buyers_name();
        ?>
</p>
					<p><strong><?php 
        _e('Address:');
        ?>
 </strong><?php 
        echo wpsc_display_purchlog_buyers_address();
        ?>
</p>

					<p><strong><?php 
        _e('Phone:');
        ?>
 </strong><?php 
        echo wpsc_display_purchlog_buyers_phone();
        ?>
</p>
					<p><strong><?php 
        _e('Email:');
        ?>
 </strong><a href="mailto:<?php 
        echo wpsc_display_purchlog_buyers_email();
        ?>
?subject=Message From '<?php 
        echo get_option('siteurl');
        ?>
'"><?php 
        echo wpsc_display_purchlog_buyers_email();
        ?>
</a></p>
					<p><strong><?php 
        _e('Payment Method:');
        ?>
 </strong><?php 
        echo wpsc_display_purchlog_paymentmethod();
        ?>
</p>
					<?php 
        if (wpsc_display_purchlog_display_howtheyfoundus()) {
            ?>
					<p><strong><?php 
            _e('How User Found Us:');
            ?>
 </strong><?php 
            echo wpsc_display_purchlog_howtheyfoundus();
            ?>
</p>
					<?php 
        }
        ?>
				</div>
			
				<div id='wpsc_items_ordered'>
					<br />
					<h3><?php 
        _e('Items Ordered');
        ?>
</h3>
					<table class="widefat" cellspacing="0">
						<thead>
							<tr>
						<?php 
        print_column_headers('display-purchaselog-details');
        ?>
							</tr>
						</thead>
					
						<tfoot>
							<tr>
						<?php 
        ?>
<?php// print_column_headers('display-purchaselog-details', false); ?>
							</tr>
						</tfoot>
					
						<tbody>
						<?php 
        wpsc_display_purchlog_details();
        ?>
						<tr> &nbsp;</tr>

						<tr class="wpsc_purchaselog_start_totals">
							<td colspan="5">
								<?php 
        if (wpsc_purchlog_has_discount_data()) {
            ?>
								<?php 
            _e('Coupon Code');
            ?>
: <?php 
            echo wpsc_display_purchlog_discount_data();
            ?>
								<?php 
        }
        ?>
							</td>
							<th><?php 
        _e('Discount');
        ?>
 </th>
							<td><?php 
        echo wpsc_display_purchlog_discount();
        ?>
</td>
						</tr>
						
						<tr>
							<td colspan='5'></td>
							<th><?php 
        _e('Shipping');
        ?>
 </th>
							<td><?php 
        echo wpsc_display_purchlog_shipping();
        ?>
</td>
						</tr>
						<tr>
							<td colspan='5'></td>
							<th><?php 
        _e('Total');
        ?>
 </th>
							<td><?php 
        echo wpsc_display_purchlog_totalprice();
        ?>
</td>
						</tr>
						</tbody>
				</table>
				<div id='wpsc_purchlog_order_status'>
					<form action='' method='post'>
					<p><label for='<?php 
        echo $_GET['purchaselog_id'];
        ?>
'><?php 
        _e('Order Status:');
        ?>
</label><select class='selector' name='<?php 
        echo $_GET['purchaselog_id'];
        ?>
' title='<?php 
        echo $_GET['purchaselog_id'];
        ?>
' >
	 			<?php 
        while (wpsc_have_purch_items_statuses()) {
            wpsc_the_purch_status();
            ?>
	 				<option value='<?php 
            echo wpsc_the_purch_status_id();
            ?>
' <?php 
            echo wpsc_purchlog_is_checked_status();
            ?>
 ><?php 
            echo wpsc_the_purch_status_name();
            ?>
 </option>
	 			<?php 
        }
        ?>
		 			</select></p>
		 			</form>
 			</div>
 				<?php 
        wpsc_purchlogs_custom_fields();
        ?>
 				
 				
 				<!-- Start Order Notes (by Ben) -->
 				<?php 
        wpsc_purchlogs_notes();
        ?>
				<!-- End Order Notes (by Ben) -->
				
				<?php 
        wpsc_custom_checkout_fields();
        ?>
 				
				</div>
				</div>
				
				<div id='wpsc_purchlogitems_links'>
				<h3><?php 
        _e('Actions');
        ?>
</h3>
				<?php 
        do_action('wpsc_purchlogitem_links_start');
        ?>
				<?php 
        if (wpsc_purchlogs_have_downloads_locked() != false) {
            ?>
<img src='<?php 
            echo WPSC_URL;
            ?>
/images/lock_open.png' alt='clear lock icon' />&ensp;<a href='<?php 
            echo $_SERVER['REQUEST_URI'] . '&amp;wpsc_admin_action=clear_locks';
            ?>
'><?php 
            echo wpsc_purchlogs_have_downloads_locked();
            ?>
</a><br /><br class='small' />
				<?php 
        }
        ?>
<img src='<?php 
        echo WPSC_URL;
        ?>
/images/printer.png' alt='printer icon' />&ensp;<a href='<?php 
        echo add_query_arg('wpsc_admin_action', 'wpsc_display_invoice');
        ?>
'><?php 
        echo __('View Packing Slip', 'wpsc');
        ?>
</a>
		
<br /><br class='small' /><img src='<?php 
        echo WPSC_URL;
        ?>
/images/email_go.png' alt='email icon' />&ensp;<a href='<?php 
        echo add_query_arg('email_buyer_id', $_GET['purchaselog_id']);
        ?>
'><?php 
        echo __('Resend Receipt to Buyer', 'wpsc');
        ?>
</a>
		  
<br /><br class='small' /><a class='submitdelete' title='<?php 
        echo attribute_escape(__('Delete this log'));
        ?>
' href='<?php 
        echo wp_nonce_url("admin.php?wpsc_admin_action=delete_purchlog&amp;purchlog_id=" . $_GET['purchaselog_id'], 'delete_purchlog_' . $_GET['purchaselog_id']);
        ?>
' onclick="if ( confirm(' <?php 
        echo js_escape(sprintf(__("You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete."), wpsc_purchaselog_details_date()));
        ?>
') ) { return true;}return false;"><img src='<?php 
        echo WPSC_URL . "/images/cross.png";
        ?>
' alt='delete icon' />               &nbsp;<?php 
        echo __('Remove this record', 'wpsc');
        ?>
</a>

<br /><br class='small' />&emsp;&ensp; 	<a href='<?php 
        echo $page_back;
        ?>
'><?php 
        echo __('Go Back', 'wpsc');
        ?>
</a>
<br /><br />
			</div>
			</div>
			<br />
			<?php 
    }
    ?>
	</div>
	<?php 
}
コード例 #8
0
function wpsc_is_tax_included()
{
    return wpsc_tax_isincluded();
}
コード例 #9
0
 /**
  * construct value array method, converts the data gathered by the base class code to something acceptable to the gateway
  * @access private
  * @param boolean $aggregate Whether to aggregate the cart data or not. Defaults to false.
  * @return array $paypal_vars The paypal vars
  */
 function _construct_value_array($aggregate = false)
 {
     global $wpdb, $wpsc_cart;
     $paypal_vars = array();
     $add_tax = !wpsc_tax_isincluded();
     $buy_now = defined('WPSC_PAYPAL_BUY_NOW') && WPSC_PAYPAL_BUY_NOW;
     $return_url = add_query_arg('sessionid', $this->cart_data['session_id'], $this->cart_data['transaction_results_url']);
     if ($buy_now) {
         $return_url = add_query_arg('wpsc_buy_now_return', 1, $return_url);
     }
     // Store settings to be sent to paypal
     $paypal_vars += array('business' => get_option('paypal_multiple_business'), 'return' => $return_url, 'cancel_return' => $this->cart_data['transaction_results_url'], 'rm' => '2', 'currency_code' => $this->get_paypal_currency_code(), 'lc' => $this->cart_data['store_currency'], 'no_note' => '1', 'charset' => 'utf-8');
     // IPN data
     if (get_option('paypal_ipn') == 1) {
         $notify_url = $this->cart_data['notification_url'];
         $notify_url = add_query_arg('gateway', 'wpsc_merchant_paypal_standard', $notify_url);
         $notify_url = apply_filters('wpsc_paypal_standard_notify_url', $notify_url);
         $paypal_vars += array('notify_url' => $notify_url);
     }
     // Customer details
     $paypal_vars += array('email' => $this->cart_data['email_address'], 'first_name' => $this->cart_data['billing_address']['first_name'], 'last_name' => $this->cart_data['billing_address']['last_name'], 'address1' => $this->cart_data['billing_address']['address'], 'city' => $this->cart_data['billing_address']['city'], 'state' => isset($this->cart_data['billing_address']['state']) ? $this->cart_data['billing_address']['state'] : '', 'zip' => $this->cart_data['billing_address']['post_code'], 'country' => isset($this->cart_data['billing_address']['country']) ? $this->cart_data['billing_address']['country'] : '');
     // Shipping
     if ((bool) get_option('paypal_ship') && !$buy_now) {
         $paypal_vars += array('address_override' => get_option('address_override'), 'no_shipping' => '0');
         if ($paypal_vars['country'] == 'UK') {
             $paypal_vars['country'] = 'GB';
         }
     } else {
         $paypal_vars += array('no_shipping' => '1');
     }
     // Order settings to be sent to paypal
     $paypal_vars += array('invoice' => $this->cart_data['session_id']);
     if ($buy_now) {
         $paypal_vars['custom'] = 'buy_now';
     }
     // Two cases:
     // - We're dealing with a subscription
     // - We're dealing with a normal cart
     if ($this->cart_data['is_subscription']) {
         $paypal_vars += array('cmd' => '_xclick-subscriptions');
         $reprocessed_cart_data['shopping_cart'] = array('is_used' => false, 'price' => 0, 'length' => 1, 'unit' => 'd', 'times_to_rebill' => 1);
         $reprocessed_cart_data['subscription'] = array('is_used' => false, 'price' => 0, 'length' => 1, 'unit' => 'D', 'times_to_rebill' => 1);
         foreach ($this->cart_items as $cart_row) {
             if ($cart_row['is_recurring']) {
                 $reprocessed_cart_data['subscription']['is_used'] = true;
                 $reprocessed_cart_data['subscription']['price'] = $this->convert($cart_row['price']);
                 $reprocessed_cart_data['subscription']['length'] = $cart_row['recurring_data']['rebill_interval']['length'];
                 $reprocessed_cart_data['subscription']['unit'] = strtoupper($cart_row['recurring_data']['rebill_interval']['unit']);
                 $reprocessed_cart_data['subscription']['times_to_rebill'] = $cart_row['recurring_data']['times_to_rebill'];
             } else {
                 $item_cost = ($cart_row['price'] + $cart_row['shipping'] + $cart_row['tax']) * $cart_row['quantity'];
                 if ($item_cost > 0) {
                     $reprocessed_cart_data['shopping_cart']['price'] += $item_cost;
                     $reprocessed_cart_data['shopping_cart']['is_used'] = true;
                 }
             }
             $paypal_vars += array('item_name' => apply_filters('the_title', $cart_row['name']), 'src' => '1');
             // This can be false, we don't need to have additional items in the cart/
             if ($reprocessed_cart_data['shopping_cart']['is_used']) {
                 $paypal_vars += array("a1" => $this->convert($reprocessed_cart_data['shopping_cart']['price']), "p1" => $reprocessed_cart_data['shopping_cart']['length'], "t1" => $reprocessed_cart_data['shopping_cart']['unit']);
             }
             // We need at least one subscription product,
             // If this is not true, something is rather wrong.
             if ($reprocessed_cart_data['subscription']['is_used']) {
                 $paypal_vars += array("a3" => $this->convert($reprocessed_cart_data['subscription']['price']), "p3" => $reprocessed_cart_data['subscription']['length'], "t3" => $reprocessed_cart_data['subscription']['unit']);
                 // If the srt value for the number of times to rebill is not greater than 1,
                 // paypal won't accept the transaction.
                 if ($reprocessed_cart_data['subscription']['times_to_rebill'] > 1) {
                     $paypal_vars += array('srt' => $reprocessed_cart_data['subscription']['times_to_rebill']);
                 }
             }
         }
         // end foreach cart item
     } else {
         if ($buy_now) {
             $paypal_vars['cmd'] = '_xclick';
         } else {
             $paypal_vars += array('upload' => '1', 'cmd' => '_ext-enter', 'redirect_cmd' => '_cart');
         }
         $free_shipping = false;
         $coupon = wpsc_get_customer_meta('coupon');
         if ($coupon) {
             $coupon = new wpsc_coupons($coupon);
             $free_shipping = $coupon->is_free_shipping();
         }
         if ($this->cart_data['has_discounts'] && $free_shipping) {
             $handling = 0;
         } else {
             $handling = $this->cart_data['base_shipping'];
         }
         $tax_total = 0;
         if ($add_tax) {
             $tax_total = $this->cart_data['cart_tax'];
         }
         // Set base shipping
         $paypal_vars += array('handling_cart' => $this->convert($handling));
         // Stick the cart item values together here
         $i = 1;
         if (!$buy_now) {
             if (!$aggregate) {
                 foreach ($this->cart_items as $cart_row) {
                     $item_number = get_post_meta($cart_row['product_id'], '_wpsc_sku', true);
                     if (!$item_number) {
                         $item_number = $cart_row['product_id'];
                     }
                     $paypal_vars += array("item_name_{$i}" => apply_filters('the_title', $cart_row['name']), "amount_{$i}" => $this->convert($cart_row['price']), "quantity_{$i}" => $cart_row['quantity'], "item_number_{$i}" => $item_number);
                     if (!$free_shipping) {
                         $paypal_vars += array("shipping_{$i}" => $this->convert($cart_row['shipping'] / $cart_row['quantity']), "shipping2_{$i}" => $this->convert($cart_row['shipping'] / $cart_row['quantity']), "handling_{$i}" => '');
                     }
                     if ($add_tax && !empty($cart_row['tax'])) {
                         $tax_total += $cart_row['tax'];
                     }
                     ++$i;
                 }
                 if ($this->cart_data['has_discounts'] && !$free_shipping) {
                     $paypal_vars['discount_amount_cart'] = $this->convert($this->cart_data['cart_discount_value']);
                     $subtotal = $wpsc_cart->calculate_subtotal();
                     if ($this->cart_data['cart_discount_value'] >= $wpsc_cart->calculate_subtotal()) {
                         $paypal_vars['discount_amount_cart'] = $this->convert($subtotal) - 0.01;
                         if (!empty($paypal_vars['handling_cart'])) {
                             $paypal_vars['handling_cart'] -= 0.01;
                         }
                     }
                 }
             } else {
                 $paypal_vars['item_name_' . $i] = __("Your Shopping Cart", 'wp-e-commerce');
                 $paypal_vars['amount_' . $i] = $this->convert($this->cart_data['total_price']) - $this->convert($this->cart_data['base_shipping']);
                 $paypal_vars['quantity_' . $i] = 1;
                 $paypal_vars['shipping_' . $i] = 0;
                 $paypal_vars['shipping2_' . $i] = 0;
                 $paypal_vars['handling_' . $i] = 0;
             }
             $paypal_vars['tax_cart'] = $aggregate ? 0 : $this->convert($tax_total);
         } else {
             $cart_row = $this->cart_items[0];
             $item_number = get_post_meta($cart_row['product_id'], '_wpsc_sku', true);
             $paypal_vars += array('item_name' => apply_filters('the_title', $cart_row['name']), 'item_number' => $item_number, 'amount' => $this->convert($cart_row['price']), 'quantity' => $cart_row['quantity'], 'handling' => $this->convert($handling));
         }
     }
     $paypal_vars = apply_filters('wpsc_paypal_standard_post_data', $paypal_vars);
     $paypal_vars['bn'] = 'WPeC_Cart_WPS';
     return $paypal_vars;
 }
コード例 #10
0
ファイル: cart.class.php プロジェクト: alx/SBek-Arak
 /**
  * save to database method
  * @access public
  *
  * @param integer purchase log id
  */
 function save_to_db($purchase_log_id)
 {
     global $wpdb, $wpsc_shipping_modules;
     if ($method === null) {
         $method = $this->cart->selected_shipping_method;
     }
     if (method_exists($wpsc_shipping_modules[$method], "get_item_shipping")) {
         $shipping = $wpsc_shipping_modules[$this->cart->selected_shipping_method]->get_item_shipping($this);
     }
     if ($this->cart->has_total_shipping_discount()) {
         $shipping = 0;
     }
     if ($this->apply_tax == true && wpsc_tax_isincluded() == false) {
         if (is_numeric($this->custom_tax_rate)) {
             $tax_rate = $this->custom_tax_rate;
         } else {
             $tax_rate = $this->cart->tax_percentage;
         }
         $tax = $this->unit_price * ($tax_rate / 100);
     } else {
         $tax = 0;
         $tax_rate = 0;
     }
     $wpdb->query($wpdb->prepare("INSERT INTO `" . WPSC_TABLE_CART_CONTENTS . "` (`prodid`, `name`, `purchaseid`, `price`, `pnp`,`tax_charged`, `gst`, `quantity`, `donation`, `no_shipping`, `custom_message`, `files`, `meta`) VALUES ('%d', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%d', '0', '%s', '%s', NULL)", $this->product_id, $this->product_name, $purchase_log_id, $this->unit_price, (double) $shipping, (double) $tax, (double) $tax_rate, $this->quantity, $this->is_donation, $this->custom_message, serialize($this->custom_file)));
     $cart_id = $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `" . WPSC_TABLE_CART_CONTENTS . "` LIMIT 1");
     foreach ((array) $this->variation_data as $variation_row) {
         $wpdb->query("INSERT INTO `" . WPSC_TABLE_CART_ITEM_VARIATIONS . "` ( `cart_id` , `variation_id` , `value_id` ) VALUES ( '" . $cart_id . "', '" . $variation_row['variation_id'] . "', '" . $variation_row['id'] . "' );");
     }
     $downloads = get_option('max_downloads');
     if ($this->is_downloadable == true) {
         //$product_files = $wpdb->get_row("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` = '".$this->product_id."' AND `meta_key` = 'product_files'", ARRAY_A);
         //$product_files = unserialize($product_files["meta_value"]);
         $product_files = get_product_meta($this->product_id, 'product_files');
         if ($this->file_id != null) {
             // if the file is downloadable, check that the file is real
             if ($wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id` IN ('{$this->file_id}')")) {
                 $unique_id = sha1(uniqid(mt_rand(), true));
                 $wpdb->query("INSERT INTO `" . WPSC_TABLE_DOWNLOAD_STATUS . "` (`product_id` , `fileid` , `purchid` , `cartid`, `uniqueid`, `downloads` , `active` , `datetime` ) VALUES ( '{$this->product_id}', '{$this->file_id}', '{$purchase_log_id}', '{$cart_id}', '{$unique_id}', '{$downloads}', '0', NOW( ));");
             }
         } else {
             foreach ($product_files as $file) {
                 // if the file is downloadable, check that the file is real
                 if ($wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id` IN ('{$file}')")) {
                     $unique_id = sha1(uniqid(mt_rand(), true));
                     $wpdb->query("INSERT INTO `" . WPSC_TABLE_DOWNLOAD_STATUS . "` (`product_id` , `fileid` , `purchid` , `cartid`, `uniqueid`, `downloads` , `active` , `datetime` ) VALUES ( '{$this->product_id}', '{$file}', '{$purchase_log_id}', '{$cart_id}', '{$unique_id}', '{$downloads}', '0', NOW( ));");
                 }
             }
         }
     }
     do_action('wpsc_save_cart_item', $cart_id, $this->product_id);
 }
コード例 #11
0
/**
 * tax total function, no parameters
 *
 * @uses wpsc_cart
 *
 * @return float the total weight of the cart
 */
function wpsc_cart_tax($format_for_display = true)
{
    global $wpsc_cart;
    $cart_tax = $format_for_display ? '' : 0;
    if (_wpsc_verify_global_cart_has_been_initialized(__FUNCTION__)) {
        if ($format_for_display) {
            if (!wpsc_tax_isincluded()) {
                $cart_tax = wpsc_currency_display($wpsc_cart->calculate_total_tax());
            } else {
                $cart_tax = '(' . wpsc_currency_display($wpsc_cart->calculate_total_tax()) . ')';
            }
        } else {
            $cart_tax = $wpsc_cart->calculate_total_tax();
        }
    }
    return $cart_tax;
}
コード例 #12
0
function wpsc_purchaselog_details_tax()
{
    global $purchlogitem, $wpsc_cart;
    //	exit('<pre>'.print_r($purchlogitem->purchitem, true).'</pre>');
    if (wpsc_tax_isincluded() == false) {
        return nzshpcrt_currency_display($purchlogitem->purchitem->tax_charged, true);
    } else {
        //exit('<pre>'.print_r($purchlogitem,true).'</pre>');
        if ($purchlogitem->purchitem->notax == 0) {
            if ($purchlogitem->purchitem->price == null && $id != null) {
                foreach ((array) $purchlogitem->allcartcontent as $cartcontent) {
                    //exit('<pre>'.print_r($cartcontent, true).'</pre>');
                    if ($cartcontent->prodid == $id && $cartcontent->notax == 1) {
                        return '-';
                    }
                }
                $price = $id;
            } else {
                $price = $purchlogitem->purchitem->price;
            }
            $tax = $price / (100 + $wpsc_cart->tax_percentage) * $wpsc_cart->tax_percentage;
            $tax = $wpsc_cart->process_as_currency($tax);
            return $tax . ' (' . $wpsc_cart->tax_percentage . '%)';
        } else {
            //			$tax = 0;
            return '-';
        }
    }
}
コード例 #13
0
function wpsc_packing_slip($purchase_id)
{
    global $wpdb, $purchlogitem, $wpsc_cart, $purchlog;
    if (isset($_REQUEST['purchaselog_id'])) {
        $purchlogitem = new wpsc_purchaselogs_items((int) $_REQUEST['purchaselog_id']);
    }
    $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  `log_id` = '".(int)$purchase_id."'";
        			$input_data = $wpdb->get_results($form_sql,ARRAY_A);
        */
        echo "<tr class='heading'><td colspan='2'><strong>Billing Info</strong></td></tr>";
        foreach ((array) $purchlogitem->userinfo as $userinfo) {
            if ($userinfo['unique_name'] != 'billingcountry') {
                echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
            } else {
                $userinfo['value'] = maybe_unserialize($userinfo['value']);
                if (is_array($userinfo['value'])) {
                    if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . $userinfo['value'][1] . "</td></tr>";
                    } elseif (is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "</td></tr>";
                    }
                    if (!empty($userinfo['value'][0])) {
                        echo "<tr><td>Country: </td><td>" . $userinfo['value'][0] . "</td></tr>";
                    }
                } else {
                    echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
                }
            }
        }
        echo "<tr class='heading'><td colspan='2'><strong>Shipping Info</strong></td></tr>";
        foreach ((array) $purchlogitem->shippinginfo as $userinfo) {
            if ($userinfo['unique_name'] != 'shippingcountry' && $userinfo['unique_name'] != 'shippingstate') {
                echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
            } elseif ($userinfo['unique_name'] == 'shippingcountry') {
                $userinfo['value'] = maybe_unserialize($userinfo['value']);
                if (is_array($userinfo['value'])) {
                    if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . $userinfo['value'][1] . "</td></tr>";
                    } elseif (is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "</td></tr>";
                    }
                    if (!empty($userinfo['value'][0])) {
                        echo "<tr><td>Country: </td><td>" . $userinfo['value'][0] . "</td></tr>";
                    }
                } else {
                    echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
                }
            } elseif ($userinfo['unique_name'] == 'shippingstate') {
                if (!empty($userinfo['value']) && !is_numeric($userinfo['value'])) {
                    echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td</tr>>";
                } elseif (is_numeric($userinfo['value'])) {
                    echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'], 'name') . "</td></tr>";
                }
            }
        }
        //		echo('<pre>'.print_r($purchlogitem,true).'</pre>');
        /*
        	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);
            // exit('<pre>'.print_r($purch_data, true).'</pre>');
                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 "  <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r";
                    }
                    echo "  <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_country($purch_data['billing_country'])."</td></tr>\n\r";
                    break;
                        
                    case 'delivery_country':
                    echo "  <tr><td>".$form_field['name'].":</td><td>".wpsc_get_country($purch_data['shipping_country'])."</td></tr>\n\r";
                    break;
                        
                    case 'heading':
                    echo "  <tr><td colspan='2'><strong>".wp_kses($form_field['name'], array()).":</strong></td></tr>\n\r";
                    break;
                    
                    default:
                    if($form_field['unique_name'] == 'shippingstate'){
                    	echo "  <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_region($purch_data['shipping_region'])."</td></tr>\n\r";
                    }else{
                    	echo "  <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 "  <tr><td>".__('Name', 'wpsc').":</td><td>".$purch_data['firstname']." ".$purch_data['lastname']."</td></tr>\n\r";
                echo "  <tr><td>".__('Address', 'wpsc').":</td><td>".$purch_data['address']."</td></tr>\n\r";
                echo "  <tr><td>".__('Phone', 'wpsc').":</td><td>".$purch_data['phone']."</td></tr>\n\r";
                echo "  <tr><td>".__('Email', 'wpsc').":</td><td>".$purch_data['email']."</td></tr>\n\r";
        			}
        */
        if (get_option('payment_method') == 2) {
            $gateway_name = '';
            foreach ($GLOBALS['nzshpcrt_gateways'] as $gateway) {
                if ($purch_data['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purch_data['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = "Manual Payment";
                }
            }
        }
        // 			echo "  <tr><td colspan='2'></td></tr>\n\r";
        // 			echo "  <tr><td>".__('Payment Method', 'wpsc').":</td><td>".$gateway_name."</td></tr>\n\r";
        // 			//echo "  <tr><td>".__('Purchase No.', 'wpsc').":</td><td>".$purch_data['id']."</td></tr>\n\r";
        // 			echo "  <tr><td>".__('How The Customer Found Us', 'wpsc').":</td><td>".$purch_data['find_us']."</td></tr>\n\r";
        // 			$engrave_line = explode(",",$purch_data['engravetext']);
        // 			echo "  <tr><td>".__('Engrave text', 'wpsc')."</td><td></td></tr>\n\r";
        // 			echo "  <tr><td>".__('Line 1', 'wpsc').":</td><td>".$engrave_line[0]."</td></tr>\n\r";
        // 			echo "  <tr><td>".__('Line 2', 'wpsc').":</td><td>".$engrave_line[1]."</td></tr>\n\r";
        // 			if($purch_data['transactid'] != '') {
        // 				echo "  <tr><td>".__('Transaction Id', 'wpsc').":</td><td>".$purch_data['transactid']."</td></tr>\n\r";
        // 			}
        echo "</table>\n\r";
        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>" . wpsc_display_tax_label(false) . "</th>";
        echo '</tr>';
        $endtotal = 0;
        $all_donations = true;
        $all_no_shipping = true;
        $file_link_list = array();
        //			exit('<pre>'.print_r($cart_log,true).'</pre>');
        foreach ($cart_log as $cart_row) {
            $purchlogitem->the_purch_item();
            //			exit('<pre>'.print_r, true).'</pre>');
            $alternate = "";
            $j++;
            if ($j % 2 != 0) {
                $alternate = "class='alt'";
            }
            $productsql = "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`=" . $cart_row['prodid'] . "";
            $product_data = $wpdb->get_results($productsql, ARRAY_A);
            $variation_sql = "SELECT * FROM `" . WPSC_TABLE_CART_ITEM_VARIATIONS . "` WHERE `cart_id`='" . $cart_row['id'] . "'";
            $variation_data = $wpdb->get_results($variation_sql, ARRAY_A);
            $variation_count = count($variation_data);
            if ($variation_count > 1) {
                $variation_list = " (";
                $i = 0;
                foreach ($variation_data as $variation) {
                    if ($i > 0) {
                        $variation_list .= ", ";
                    }
                    $value_id = $variation['value_id'];
                    $value_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A);
                    $variation_list .= $value_data[0]['name'];
                    $i++;
                }
                $variation_list .= ")";
            } else {
                if ($variation_count == 1) {
                    $value_id = $variation_data[0]['value_id'];
                    $value_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A);
                    $variation_list = " (" . $value_data[0]['name'] . ")";
                } else {
                    $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 $product_data[0]['name'];
            echo stripslashes($variation_list);
            echo " </td>";
            echo " <td>";
            echo nzshpcrt_currency_display($price, 1);
            echo " </td>";
            echo " <td>";
            echo nzshpcrt_currency_display($shipping, 1);
            echo " </td>";
            echo '<td>';
            if (wpsc_tax_isincluded()) {
                echo wpsc_purchaselog_details_tax();
            } else {
                echo nzshpcrt_currency_display($cart_row['tax_charged'], 1);
            }
            echo '<td>';
            echo '</tr>';
        }
        echo "</table>";
        echo '<table class="packing-slip-totals">';
        echo '<tr><th>Base Shipping</th><td>' . nzshpcrt_currency_display($purch_data['base_shipping'], 1) . '</td></tr>';
        echo '<tr><th>Total Shipping</th><td>' . nzshpcrt_currency_display($purch_data['base_shipping'] + $total_shipping, 1) . '</td></tr>';
        echo '<tr><th>Total Price</th><td>' . nzshpcrt_currency_display($purch_data['totalprice'], 1) . '</td></tr>';
        echo '</table>';
        echo "</div>\n\r";
    } else {
        echo "<br />" . __('This users cart was empty', 'wpsc');
    }
}
コード例 #14
0
function wpsc_options_general()
{
    global $wpdb;
    ?>
	<form name='cart_options' id='cart_options' method='post' action=''>
	<div id="options_general">
		<h2><?php 
    _e('General Settings', 'wpsc');
    ?>
</h2>
		<?php 
    /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
    wpsc_settings_page_update_notification();
    ?>
		<table class='wpsc_options form-table'>
		<tr>
			<th scope="row"><?php 
    echo __('Base Country/Region', 'wpsc');
    ?>
: </th>
			<td>
				<select name='wpsc_options[base_country]' onchange='submit_change_country();'>
				<?php 
    echo country_list(get_option('base_country'));
    ?>
				</select>
				<span id='options_country'>
				<?php 
    $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('" . get_option('base_country') . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A);
    if ($region_list != null) {
        ?>
					<select name='wpsc_options[base_region]'>
						<?php 
        foreach ($region_list as $region) {
            if (get_option('base_region') == $region['id']) {
                $selected = "selected='selected'";
            } else {
                $selected = "";
            }
            ?>
						<option value='<?php 
            echo $region['id'];
            ?>
' <?php 
            echo $selected;
            ?>
 ><?php 
            echo $region['name'];
            ?>
</option>	<?php 
        }
        ?>
					</select>
				   
		<?php 
    }
    ?>
				</span>
				<br /><?php 
    echo __('Select your primary business location.', 'wpsc');
    ?>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php 
    echo __('Tax Settings', 'wpsc');
    ?>
:</th>
			<td>
				<span id='options_region'>
				<?php 
    $country_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . get_option('base_country') . "' LIMIT 1", ARRAY_A);
    echo $country_data['country'];
    $region_count = $wpdb->get_var("SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "`  WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . get_option('base_country') . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`");
    if ($country_data['has_regions'] == 1) {
        ?>
&nbsp;&nbsp;&nbsp;&nbsp;<a href='<?php 
        echo add_query_arg(array('page' => 'wpsc-settings', 'isocode' => get_option('base_country')));
        ?>
'><?php 
        echo $region_count;
        ?>
 Regions</a>
		<?php 
    } else {
        ?>
					<input type='hidden' name='country_id' value='<?php 
        echo $country_data['id'];
        ?>
' />
					&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='country_tax' class='tax_forms' maxlength='5' size='5' value='<?php 
        echo $country_data['tax'];
        ?>
' />%
		<?php 
    }
    ?>
				</span>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php 
    _e('Tax Included in prices', 'wpsc');
    ?>
:</th>		
			<td>
				<?php 
    $tax_inprice0 = '';
    $tax_inprice1 = '';
    if (wpsc_tax_isincluded()) {
        $tax_inprice1 = 'checked="checked"';
    } else {
        $tax_inprice0 = 'checked="checked"';
    }
    ?>
				<input <?php 
    echo $tax_inprice1;
    ?>
 type='radio' name='wpsc_options[tax_inprice]' value='1' id='tax_inprice1' />
				<label for='tax_inprice1'><?php 
    echo __('Yes', 'wpsc');
    ?>
</label>
				<input <?php 
    echo $tax_inprice0;
    ?>
 type='radio' name='wpsc_options[tax_inprice]' value='0' id='tax_inprice0' />
				<label for='tax_inprice1'><?php 
    echo __('No', 'wpsc');
    ?>
</label>
			</td>
		</tr>

		<?php 
    /* START OF TARGET MARKET SELECTION */
    $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC ", ARRAY_A);
    ?>
		<tr>
			<th scope="row">
			<?php 
    echo __('Target Markets', 'wpsc');
    ?>
:
			</th>
			<td>
				<?php 
    // check for the suhosin module
    if (@extension_loaded('suhosin') && @ini_get('suhosin.post.max_vars') > 0 && @ini_get('suhosin.post.max_vars') < 500) {
        echo "<em>" . __("The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.\r\n\t\t\t", 'wpsc') . "</em>";
    } else {
        ?>
					<span>Select: <a href='<?php 
        echo add_query_arg(array('selected_all' => 'all'));
        ?>
' class='wpsc_select_all'>All</a>&nbsp; <a href='<?php 
        echo add_query_arg(array('selected_all' => 'none'));
        ?>
' class='wpsc_select_none'>None</a></span><br />

					<div id='resizeable' class='ui-widget-content multiple-select'>
						<?php 
        foreach ((array) $countrylist as $country) {
            $country['country'] = htmlspecialchars($country['country']);
            if ($country['visible'] == 1) {
                ?>
									<input type='checkbox' name='countrylist2[]' value='<?php 
                echo $country['id'];
                ?>
'  checked='checked' /><?php 
                echo $country['country'];
                ?>
<br />
						<?php 
            } else {
                ?>
									<input type='checkbox' name='countrylist2[]' value='<?php 
                echo $country['id'];
                ?>
'  /><?php 
                echo $country['country'];
                ?>
<br />
						<?php 
            }
        }
        ?>
		
					</div><br />
					Select the markets you are selling products to.
				<?php 
    }
    ?>
			</td>
		</tr>
		</table> 
							
		<h3 class="form_group"><?php 
    echo __('Currency Settings', 'wpsc');
    ?>
:</h3>
		<table class='wpsc_options form-table'>
		<tr>
			<th scope="row"><?php 
    echo __('Currency type', 'wpsc');
    ?>
:</th>
			<td>
				<select name='wpsc_options[currency_type]' onchange='getcurrency(this.options[this.selectedIndex].value);'>
				<?php 
    $currency_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A);
    foreach ($currency_data as $currency) {
        if (get_option('currency_type') == $currency['id']) {
            $selected = "selected='selected'";
        } else {
            $selected = "";
        }
        ?>
					<option value='<?php 
        echo $currency['id'];
        ?>
' <?php 
        echo $selected;
        ?>
 ><?php 
        echo htmlspecialchars($currency['country']);
        ?>
 (<?php 
        echo $currency['currency'];
        ?>
)</option>
		<?php 
    }
    $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A);
    if ($currency_data['symbol'] != '') {
        $currency_sign = $currency_data['symbol_html'];
    } else {
        $currency_sign = $currency_data['code'];
    }
    ?>
				</select>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php 
    echo __('Currency sign location', 'wpsc');
    ?>
:</th>
			<td>
				<?php 
    $currency_sign_location = get_option('currency_sign_location');
    $csl1 = "";
    $csl2 = "";
    $csl3 = "";
    $csl4 = "";
    switch ($currency_sign_location) {
        case 1:
            $csl1 = "checked ='checked'";
            break;
        case 2:
            $csl2 = "checked ='checked'";
            break;
        case 3:
            $csl3 = "checked ='checked'";
            break;
        case 4:
            $csl4 = "checked ='checked'";
            break;
    }
    ?>
				<input type='radio' value='1' name='wpsc_options[currency_sign_location]' id='csl1' <?php 
    echo $csl1;
    ?>
 /> 
				<label for='csl1'>100<span id='cslchar1'><?php 
    echo $currency_sign;
    ?>
</span></label> &nbsp;
				<input type='radio' value='2' name='wpsc_options[currency_sign_location]' id='csl2' <?php 
    echo $csl2;
    ?>
 /> 
				<label for='csl2'>100 <span id='cslchar2'><?php 
    echo $currency_sign;
    ?>
</span></label> &nbsp;
				<input type='radio' value='3' name='wpsc_options[currency_sign_location]' id='csl3' <?php 
    echo $csl3;
    ?>
 /> 
				<label for='csl3'><span id='cslchar3'><?php 
    echo $currency_sign;
    ?>
</span>100</label> &nbsp;
				<input type='radio' value='4' name='wpsc_options[currency_sign_location]' id='csl4' <?php 
    echo $csl4;
    ?>
 /> 
				<label for='csl4'><span id='cslchar4'><?php 
    echo $currency_sign;
    ?>
</span> 100</label>
			</td>
		</tr>
		<tr>
			<?php 
    $decimals = get_option('wpsc_hide_decimals');
    switch ($decimals) {
        case '1':
            $decimal1 = 'checked="checked"';
            break;
        case '0':
        default:
            $decimal2 = 'checked="checked"';
            break;
    }
    ?>
			<th scope="row"><?php 
    _e('Hide Decimals on Products Pages');
    ?>
</th>
			<td>
			<input type='radio' value='1' name='wpsc_options[wpsc_hide_decimals]' id='hide_decimals1' <?php 
    echo $decimal1;
    ?>
 />
			<label for='hide_decimals1'><?php 
    _e('Yes');
    ?>
</label>

			<input type='radio' value='0' name='wpsc_options[wpsc_hide_decimals]' id='hide_decimals2' <?php 
    echo $decimal2;
    ?>
 />
			<label for='hide_decimals2'><?php 
    _e('No');
    ?>
</label>
			</td>
		</tr>
		</table> 
		<div class="submit">
			<input type='hidden' name='wpsc_admin_action' value='submit_options' />
			<?php 
    wp_nonce_field('update-options', 'wpsc-update-options');
    ?>
			<input type="submit" value="<?php 
    echo __('Update &raquo;', 'wpsc');
    ?>
" name="updateoption"/>
		</div>
	</div>
	</form>
<?php 
}
コード例 #15
0
ファイル: cart.class.php プロジェクト: hornet9/Morato
 /**
  * calculate total price method
  * @access public
  *
  * @return float returns the price as a floating point value
  */
 function calculate_total_price()
 {
     if ($this->total_price == null) {
         $total = $this->calculate_subtotal();
         $total += $this->calculate_total_shipping();
         if (wpsc_tax_isincluded() == false) {
             $total += $this->calculate_total_tax();
         }
         $total -= $this->coupons_amount;
         $this->total_price = $total;
     } else {
         $total = $this->total_price;
     }
     if ($total < 0) {
         $wpsc_cart->coupons_amount += $total;
         $total = 0;
     }
     return $total;
 }