function gateway_paypal_multiple($seperator, $sessionid) { global $wpdb; $purchase_log_sql = "SELECT * FROM `" . $wpdb->prefix . "purchase_logs` WHERE `sessionid`= " . $sessionid . " LIMIT 1"; $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A); //exit(print_r($purchase_log,1)); $cart_sql = "SELECT * FROM `" . $wpdb->prefix . "cart_contents` WHERE `purchaseid`='" . $purchase_log[0]['id'] . "'"; $cart = $wpdb->get_results($cart_sql, ARRAY_A); //written by allen //exit("<pre>".print_r($cart,true)."</pre>"); $member_subtype = get_product_meta($cart[0]['prodid'], 'is_permenant', true); $status = get_product_meta($cart[0]['prodid'], 'is_membership', true); $is_member = $status; $is_perm = $member_subtype; //end of written by allen $transact_url = get_option('transact_url'); // paypal connection variables $data['business'] = get_option('paypal_multiple_business'); $data['return'] = urlencode($transact_url . $seperator . "sessionid=" . $sessionid . "&gateway=paypal"); $data['cancel_return'] = urlencode($transact_url); $data['notify_url'] = urlencode(get_option('siteurl') . "/?ipn_request=true"); $data['rm'] = '2'; // look up the currency codes and local price $currency_code = $wpdb->get_results("SELECT `code` FROM `" . $wpdb->prefix . "currency_list` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A); $local_currency_code = $currency_code[0]['code']; $paypal_currency_code = get_option('paypal_curcode'); //exit(get_option('currency_type'). " ".$paypal_currency_code); // Stupid paypal only accepts payments in one of 5 currencies. Convert from the currency of the users shopping cart to the curency which the user has specified in their paypal preferences. $curr = new CURRENCYCONVERTER(); $data['currency_code'] = $paypal_currency_code; // $data['lc'] = 'US'; $data['lc'] = 'NZ'; $data['bn'] = 'wp_e-commerce'; $data['no_shipping'] = '2'; if (get_option('address_override') == 1) { $data['address_override'] = '1'; } $data['no_note'] = '1'; switch ($paypal_currency_code) { case "JPY": $decimal_places = 0; break; case "HUF": $decimal_places = 0; default: $decimal_places = 2; break; } $i = 1; $all_donations = true; $all_no_shipping = true; $total = nzshpcrt_overall_total_price($_SESSION['selected_country'], false, true); $discount = nzshpcrt_apply_coupon($total, $_SESSION['coupon_num']); if ($discount > 0 && $_SESSION['coupon_num'] != null) { $data['item_name_' . $i] = "Your Shopping Cart"; $data['amount_' . $i] = number_format(sprintf("%01.2f", $discount), $decimal_places, '.', ''); $data['quantity_' . $i] = 1; // $data['item_number_'.$i] = 0; $data['shipping_' . $i] = 0; $data['shipping2_' . $i] = 0; $data['handling_' . $i] = 0; $i++; } else { foreach ($cart as $item) { $product_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `id`='" . $item['prodid'] . "' LIMIT 1", ARRAY_A); $product_data = $product_data[0]; $variation_count = count($product_variations); $variation_sql = "SELECT * FROM `" . $wpdb->prefix . "cart_item_variations` WHERE `cart_id`='" . $item['id'] . "'"; $variation_data = $wpdb->get_results($variation_sql, ARRAY_A); $variation_count = count($variation_data); if ($variation_count >= 1) { $variation_list = " ("; $j = 0; foreach ($variation_data as $variation) { if ($j > 0) { $variation_list .= ", "; } $value_id = $variation['value_id']; $value_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "variation_values` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list .= $value_data[0]['name']; $j++; } $variation_list .= ")"; } else { $variation_list = ''; } $local_currency_productprice = $item['price']; $local_currency_shipping = $item['pnp']; //exit($local_currency_productprice . " " . $local_currency_code); if ($paypal_currency_code != $local_currency_code) { $paypal_currency_productprice = $curr->convert($local_currency_productprice, $paypal_currency_code, $local_currency_code); $paypal_currency_shipping = $curr->convert($local_currency_shipping, $paypal_currency_code, $local_currency_code); } else { $paypal_currency_productprice = $local_currency_productprice; $paypal_currency_shipping = $local_currency_shipping; } //exit("---->".$paypal_currency_shipping); $data['item_name_' . $i] = urlencode(stripslashes($product_data['name']) . $variation_list); $data['amount_' . $i] = number_format(sprintf("%01.2f", $paypal_currency_productprice), $decimal_places, '.', ''); $data['quantity_' . $i] = $item['quantity']; $data['item_number_' . $i] = $product_data['id']; if ($item['donation'] != 1) { $all_donations = false; $data['shipping_' . $i] = number_format($paypal_currency_shipping, $decimal_places, '.', ''); $data['shipping2_' . $i] = number_format($paypal_currency_shipping, $decimal_places, '.', ''); } else { $data['shipping_' . $i] = number_format(0, $decimal_places, '.', ''); $data['shipping2_' . $i] = number_format(0, $decimal_places, '.', ''); } if ($product_data['no_shipping'] != 1) { $all_no_shipping = false; } $data['handling_' . $i] = ''; $i++; } } $data['tax'] = ''; $base_shipping = $purchase_log[0]['base_shipping']; //exit($base_shipping); if ($base_shipping > 0 && $all_donations == false && $all_no_shipping == false) { $data['handling_cart'] = number_format($base_shipping, $decimal_places, '.', ''); } $data['custom'] = ''; $data['invoice'] = $sessionid; // User details if ($_POST['collected_data'][get_option('paypal_form_first_name')] != '') { $data['first_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_first_name')]); } if ($_POST['collected_data'][get_option('paypal_form_last_name')] != '') { $data['last_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_last_name')]); } if ($_POST['collected_data'][get_option('paypal_form_address')] != '') { $address_rows = explode("\n\r", $_POST['collected_data'][get_option('paypal_form_address')]); $data['address1'] = urlencode(str_replace(array("\n", "\r"), '', $address_rows[0])); unset($address_rows[0]); if ($address_rows != null) { $data['address2'] = implode(", ", $address_rows); } else { $data['address2'] = ''; } } if ($_POST['collected_data'][get_option('paypal_form_city')] != '') { $data['city'] = urlencode($_POST['collected_data'][get_option('paypal_form_city')]); } if (preg_match("/^[a-zA-Z]{2}\$/", $_SESSION['selected_country'])) { $data['country'] = $_SESSION['selected_country']; } if (is_numeric($_POST['collected_data'][get_option('paypal_form_post_code')])) { $data['zip'] = urlencode($_POST['collected_data'][get_option('paypal_form_post_code')]); } // Change suggested by waxfeet@gmail.com, if email to be sent is not there, dont send an email address $email_data = $wpdb->get_results("SELECT `id`,`type` FROM `" . $wpdb->prefix . "collect_data_forms` WHERE `type` IN ('email') AND `active` = '1'", ARRAY_A); foreach ((array) $email_data as $email) { $data['email'] = $_POST['collected_data'][$email['id']]; } if ($_POST['collected_data'][get_option('email_form_field')] != null && $data['email'] == null) { $data['email'] = $_POST['collected_data'][get_option('email_form_field')]; } $data['upload'] = '1'; $data['cmd'] = "_ext-enter"; $data['redirect_cmd'] = "_cart"; $datacount = count($data); $num = 0; foreach ($data as $key => $value) { $amp = '&'; $num++; if ($num == $datacount) { $amp = ''; } //$output .= $key.'='.urlencode($value).$amp; $output .= $key . '=' . $value . $amp; } if (get_option('paypal_ipn') == 0) { //ensures that digital downloads still work for people without IPN, less secure, though //$wpdb->query("UPDATE `".$wpdb->prefix."purchase_logs` SET `processed` = '2' WHERE `sessionid` = ".$sessionid." LIMIT 1"); } //written by allen if ($is_member == '1') { $membership_length = get_product_meta($cart[0]['prodid'], 'membership_length', true); if ($is_perm == '1') { $permsub = '&src=1'; } else { $permsub = ''; } $output = 'cmd=_xclick-subscriptions&business=' . urlencode($data['business']) . '&no_note=1&item_name=' . urlencode($data['item_name_1']) . '&return=' . urlencode($data['return']) . '&cancel_return=' . urlencode($data['cancel_return']) . $permsub . '&a3=' . urlencode($data['amount_1']) . '&p3=' . urlencode($membership_length['length']) . '&t3=' . urlencode(strtoupper($membership_length['unit'])); } // echo "<a href='".get_option('paypal_multiple_url')."?".$output."'>Test the URL here</a>"; // exit("<pre>".print_r($data,true)."</pre>"); header("Location: " . get_option('paypal_multiple_url') . "?" . $output); exit; }
echo " </td>\n\r"; echo " <td colspan='2' id='checkout_total' style='vertical-align: middle;'>\n\r"; echo nzshpcrt_overall_total_price($_SESSION['selected_country'], true, false, $total); echo " </td>\n\r"; echo "</tr>\n\r"; echo "</table>"; if ($_POST['coupon_num']) { $_SESSION['nzshpcrt_totalprice'] = $total_after_discount; } else { $_SESSION['nzshpcrt_totalprice'] = $total; } if (get_option('payment_gateway') == 'google') { $google_cart = unserialize($_SESSION['google_shopping_cart']); if ($_SESSION['coupon_num']) { $overall_total = nzshpcrt_overall_total_price_numeric(null, true); $discount = $overall_total - nzshpcrt_apply_coupon($overall_total, $_SESSION['coupon_num']); $total_after_discount = $overall_total - $discount; $_SESSION['wpsc_discount'] = $discount; } else { $_SESSION['wpsc_discount'] = 0; } if ($_POST["quantity"]) { $pnp = $wpdb->get_var("SELECT SUM(pnp) FROM " . $wpdb->prefix . "product_list WHERE id IN (" . $cart_item->product_id . ")"); $local_shipping_price = nzshpcrt_determine_base_shipping(0, get_option('base_country')); $google_local_shipping = $local_shipping_price + $pnp * $_POST["quantity"]; $pnp = $wpdb->get_var("SELECT SUM(international_pnp) FROM " . $wpdb->prefix . "product_list WHERE id IN (" . $cart_item->product_id . ")"); $international_shipping_price = nzshpcrt_determine_base_shipping(0, get_option('base_country') . "-"); $google_international_shipping = $international_shipping_price + $pnp * $_POST["quantity"]; $google_cart->shipping_arr[0]->price = $google_local_shipping; $google_cart->shipping_arr[1]->price = $google_international_shipping; $google_cart->item_arr[$_POST["key"]]->quantity = $_POST["quantity"];
function nzshpcrt_overall_total_price($country_code = null, $for_display = false, $no_discount = false, $total_checkbox = 0) { /* * Determines the total in the shopping cart, adds the tax and shipping if a country code is supplied and adds the discount of a coupon code is present * Adds a dollar sign and information if there is no tax and shipping if $for_display is true */ global $wpdb; $cart =& $_SESSION['nzshpcrt_cart']; $total_quantity = 0; $total_weight = 0; $all_donations = true; $all_no_shipping = true; foreach ($cart as $cart_item) { $product_id = $cart_item->product_id; $quantity = $cart_item->quantity; $product_variations = $cart_item->product_variations; $extras = $cart_item->extras; $extras_count = count($extras); $raw_price = 0; $variation_count = count($product_variations); if ($variation_count > 0) { foreach ($product_variations as $product_variation) { $value_id = $product_variation; $value_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "variation_values` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); } } //$total_quantity += $quantity; $sql = "SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `id` = '{$product_id}' LIMIT 1"; $product = $wpdb->get_row($sql, ARRAY_A); if ($product['donation'] == 1) { $price = $quantity * $cart_item->donation_price; } else { $price = $quantity * calculate_product_price($product_id, $product_variations, 'stay', $extras); if ($country_code != null) { if ($product['notax'] != 1) { $price = nzshpcrt_calculate_tax($price, $_SESSION['selected_country'], $_SESSION['selected_region']); } $shipping = nzshpcrt_determine_item_shipping($product_id, $quantity, $country_code); $price += $shipping; } $all_donations = false; } if ($product['no_shipping'] != 1) { $all_no_shipping = false; } $total += $price; } if ($country_code != null && $all_donations == false && $all_no_shipping == false) { //echo $_SESSION['selected_country']; //exit(nzshpcrt_determine_base_shipping(0, $country_code)); $total += nzshpcrt_determine_base_shipping(0, $_SESSION['delivery_country']); } if (!empty($_SESSION['coupon_num']) && $no_discount !== true) { $total += nzshpcrt_apply_coupon($total, $_SESSION['coupon_num']) - $total; } if ($for_display === true) { $total = nzshpcrt_currency_display($total, 1); if ($country_code == null && get_option('add_plustax') == 1) { $total .= "<span class='pluspostagetax'> + " . TXT_WPSC_POSTAGE_AND_TAX . "</span>"; } } return $total; }
function nzshpcrt_shopping_basket_internals($cart, $quantity_limit = false, $no_title = false) { global $wpdb; if (get_option('permalink_structure') != '') { $seperator = "?"; } else { $seperator = "&"; } if (get_option('show_sliding_cart') == 1) { if (is_numeric($_SESSION['slider_state'])) { if ($_SESSION['slider_state'] == 0) { $collapser_image = 'plus.png'; } else { $collapser_image = 'minus.png'; } $fancy_collapser = "<a href='#' onclick='return shopping_cart_collapser()' id='fancy_collapser_link'><img src='" . WPSC_URL . "/images/{$collapser_image}' title='' alt='' id='fancy_collapser' /></a>"; } else { if ($_SESSION['nzshpcrt_cart'] == null) { $collapser_image = 'plus.png'; } else { $collapser_image = 'minus.png'; } $fancy_collapser = "<a href='#' onclick='return shopping_cart_collapser()' id='fancy_collapser_link'><img src='" . WPSC_URL . "/images/{$collapser_image}' title='' alt='' id='fancy_collapser' /></a>"; } } else { $fancy_collapser = ""; } $current_url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (get_option('cart_location') == 4) { $no_title = true; } switch (get_option('cart_location')) { case 1: if ($no_title !== true) { $output .= "<h2>" . TXT_WPSC_SHOPPINGCART . " {$fancy_collapser}</h2>"; $output .= "<span id='alt_loadingindicator'><img id='alt_loadingimage' src='" . WPSC_URL . "/images/indicator.gif' alt='Loading' title='Loading' /> " . TXT_WPSC_UDPATING . "...</span></strong><br />"; } $spacing = ""; break; case 3: if ($no_title !== true) { $output .= "<strong class='cart_title'>" . TXT_WPSC_SHOPPINGCART . " {$fancy_collapser}</strong>"; } //$output .= "<a href='#' onclick='return shopping_cart_collapser()' class='cart_title' id='fancy_collapser_link'>".TXT_WPSC_SHOPPINGCART." </a>"; break; case 4: if ($no_title !== true) { if (is_array($GLOBALS['registered_sidebars'])) { $sidebar_args = end($GLOBALS['registered_sidebars']); } else { $sidebar_args['before_title'] = "<h2>"; $sidebar_args['after_title'] = "</h2>"; } $output .= $sidebar_args['before_title'] . TXT_WPSC_SHOPPINGCART . " {$fancy_collapser}" . $sidebar_args['after_title']; } break; default: if ($no_title !== true) { //$output .= "<strong class='cart_title'>".TXT_WPSC_SHOPPINGCART." $fancy_collapser</strong>"; } break; } $cart_count = 0; foreach ((array) $cart as $item) { $cart_count += $item->quantity; } $output .= "<div id='sliding_cart'>"; if ($cart != null) { if ($quantity_limit == true || $_SESSION['out_of_stock'] == true) { $output .= "<span class='items'><span class='numberitems'>" . TXT_WPSC_NUMBEROFITEMS . ": </span><span class='cartcount'>" . $cart_count . "</span></span>"; $output .= "<span class='nomore'>" . TXT_WPSC_NOMOREAVAILABLE . "</span>"; $_SESSION['out_of_stock'] = false; } else { $output .= "<span class='items'><span class='numberitems'>" . TXT_WPSC_NUMBEROFITEMS . ": </span><span class='cartcount'>" . $cart_count . "</span></span>"; } $output .= "<table class='shoppingcart'>\n\r"; $output .= "<tr><th id='thproduct'>" . TXT_WPSC_PRODUCT . "</th><th id='thqty'>" . TXT_WPSC_QUANTITY_SHORT . "</th><th id='thprice'>" . TXT_WPSC_PRICE . "</th></tr>\n\r"; $all_donations = true; $all_no_shipping = true; $tax = 0; //written by allen $merchant_id = get_option('google_id'); // Your Merchant ID $merchant_key = get_option('google_key'); // Your Merchant Key $server_type = get_option('google_server_type'); $currency = get_option('google_cur'); if (get_option('payment_gateway') == 'google') { $google_cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency); } foreach ($cart as $cart_item) { $product_id = $cart_item->product_id; $quantity = $cart_item->quantity; //echo("<pre>".print_r($cart_item->product_variations,true)."</pre>"); $product = $wpdb->get_row("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `id` = '{$product_id}' LIMIT 1", ARRAY_A); if ($product['donation'] == 1) { if (get_option('payment_gateway') == 'google') { $google_unit_price = $cart_item->donation_price; } $price = $quantity * $cart_item->donation_price; } else { if (get_option('payment_gateway') == 'google') { $google_unit_price = calculate_product_price($product_id, $cart_item->product_variations, 'stay', $cart_item->extras); } $price = $quantity * calculate_product_price($product_id, $cart_item->product_variations, 'stay', $cart_item->extras); if ($product['notax'] != 1) { $tax += nzshpcrt_calculate_tax($price, $_SESSION['selected_country'], $_SESSION['selected_region']) - $price; } $all_donations = false; } if ($product['no_shipping'] != 1) { $all_no_shipping = false; } if ($_SESSION['delivery_country'] != null) { $total_shipping += nzshpcrt_determine_item_shipping($product['id'], $quantity, $_SESSION['delivery_country']); } $total += $price; //exit(utf8_encode('™')); $product['name'] = str_replace("™", "™", $product['name']); $product['description'] = str_replace("™", "™", $product['description']); if (get_option('payment_gateway') == 'google') { $google_item = new GoogleItem(utf8_decode($product['name']), utf8_decode($product['description']), $quantity, $google_unit_price); $google_item->SetMerchantItemId($product['id']); $google_cart->SetMerchantCalculations(get_option('siteurl'), "false", "false", "false"); //echo serialize($cart_item->product_variations); $google_item->SetMerchantPrivateItemData("some variations"); $google_cart->AddItem($google_item); } $output .= "<tr>"; if (get_option("hide_name_link") == '1') { $output .= "<td class='tdproduct'>" . $product['name'] . "</td>"; } else { $output .= "<td><a href='" . wpsc_product_url($product['id']) . "' >" . stripslashes($product['name']) . "</a></td>"; } $output .= "<td class='tdqty'>" . $quantity . "</td>"; $output .= "<td class='tdprice'>" . nzshpcrt_currency_display($price, 1) . "</td>"; $output .= "</tr>\n\r"; } //google checkout stuff. // if (get_option('payment_gateway') == 'google') { // $google_shipping = new GoogleFlatRateShipping("Flat Rate Shipping", $total_shipping); // $Gfilter = new GoogleShippingFilters(); // $google_checkout_shipping=get_option("google_shipping_country"); // $google_shipping_country_ids = implode(",",(array)$google_checkout_shipping); // if($google_shipping_country_ids != null) { // $google_shipping_country = $wpdb->get_var("SELECT isocode FROM ".$wpdb->prefix."currency_list WHERE id IN (".$google_shipping_country_ids.")"); // } // $Gfilter->AddAllowedPostalArea($google_shipping_country); // $google_shipping->AddShippingRestrictions($Gfilter); // $google_cart->AddShipping($google_shipping); // // if ($_SESSION['selected_country']=='US'){ // $tax_rule = new GoogleDefaultTaxRule(0.05); // $state_name = $wpdb->get_var("SELECT name FROM ".$wpdb->prefix."region_tax WHERE id='".$_SESSION['selected_region']."'"); // $tax_rule->SetStateAreas(array($state_name)); // $tax_rule->AddPostalArea($google_shipping_country); // $google_cart->AddDefaultTaxRules($tax_rule); // } // } //end of google checkout. $output .= "</table>"; if ($_SESSION['delivery_country'] != null) { $total_shipping = nzshpcrt_determine_base_shipping($total_shipping, $_SESSION['delivery_country']); $output .= "<span class='subtotal'><span class='subtotalhead'>" . TXT_WPSC_SUBTOTAL . ":</span>" . nzshpcrt_currency_display($total, 1) . "</span>"; if (get_option('do_not_use_shipping') != 1 && $all_donations == false && $all_no_shipping == false) { $output .= "<span class='postage'><span class='postagehead'>" . TXT_WPSC_POSTAGE . ":</span>" . nzshpcrt_currency_display($total_shipping, 1) . "</span> "; } if ($tax > 0) { $output .= "<span class='tax'><span class='taxhead'>" . TXT_WPSC_TAX . ":</span> " . nzshpcrt_currency_display($tax, 1) . "</span>"; } if ($_SESSION['coupon_num']) { $overall_total = nzshpcrt_overall_total_price_numeric($_SESSION['selected_country'], true); $discount = $overall_total - nzshpcrt_apply_coupon($overall_total, $_SESSION['coupon_num']); $total_after_discount = $overall_total - $discount; $_SESSION['wpsc_discount'] = $discount; } else { $_SESSION['wpsc_discount'] = 0; } if ($discount > 0) { $output .= "<span class='discount'><span class='discounthead'>" . TXT_WPSC_DISCOUNT . ":</span>" . nzshpcrt_currency_display($discount, 1) . "</span>"; } $output .= "<span class='total'><span class='totalhead'>" . TXT_WPSC_TOTAL . ":</span>" . nzshpcrt_overall_total_price($_SESSION['delivery_country'], true) . "</span>"; } else { if ($discount > 0) { $output .= "<span class='discount'><span class='discounthead'>" . TXT_WPSC_DISCOUNT . ":</span>" . nzshpcrt_currency_display($discount, 1) . "</span>"; } $output .= "<span class='total'><span class='totalhead'>" . TXT_WPSC_TOTAL . ":</span>" . nzshpcrt_overall_total_price($_SESSION['delivery_country'], true) . "</span>"; } if (get_option('permalink_structure') != '') { $seperator = "?"; } else { $seperator = "&"; } if ($discount > 0) { if (get_option('payment_gateway') == 'google') { $google_item = new GoogleItem(utf8_decode("Coupon Code: '" . $_SESSION['coupon_num'] . "'"), utf8_decode("A coupon redeem"), 1, -$discount); $google_item->SetMerchantPrivateItemData("Coupon Deduction"); $google_cart->AddItem($google_item); } } if (get_option('payment_gateway') == 'google') { if (!$total_shipping) { $total_shipping = 0; } $pnp = $wpdb->get_var("SELECT SUM(pnp) FROM " . $wpdb->prefix . "product_list WHERE id IN (" . $google_product_id . ")"); $local_shipping_price = nzshpcrt_determine_base_shipping($total_shipping, get_option('base_country')); $google_local_shipping = new GoogleFlatRateShipping("Local Shipping", $local_shipping_price + $pnp); $international_shipping_price = nzshpcrt_determine_base_shipping($total_shipping, get_option('base_country') . "-"); $google_international_shipping = new GoogleFlatRateShipping("International Shipping", $international_shipping_price + $pnp); $Gfilter2 = new GoogleShippingFilters(); $Gfilter = new GoogleShippingFilters(); $google_checkout_shipping = get_option("google_shipping_country"); if (!empty($google_checkout_shipping)) { $google_shipping_country_ids = implode(",", (array) $google_checkout_shipping); $google_shipping_country = $wpdb->get_results("SELECT isocode FROM " . $wpdb->prefix . "currency_list WHERE id IN (" . $google_shipping_country_ids . ")", ARRAY_A); } //exit(print_r($google_shipping_country,1)); foreach ((array) $google_shipping_country as $country) { $Gfilter->AddAllowedPostalArea($country['isocode']); $Gfilter2->AddAllowedPostalArea($country['isocode']); $Gfilter2->AddExcludedPostalArea(get_option('base_country')); if ($country['isocode'] != get_option('base_country')) { $Gfilter->AddExcludedPostalArea($country['isocode']); } } $google_local_shipping->AddShippingRestrictions($Gfilter); $google_international_shipping->AddShippingRestrictions($Gfilter2); $google_cart->AddShipping($google_local_shipping); $google_cart->AddShipping($google_international_shipping); $local_tax = $wpdb->get_var("SELECT tax from " . $wpdb->prefix . "currency_list WHERE isocode='" . get_option('base_country') . "'"); //exit($local_tax); $tax_rule = new GoogleDefaultTaxRule($local_tax / 100); if ($_SESSION['selected_country'] == 'US' && get_option('base_country') == 'US') { $state_name = $wpdb->get_var("SELECT name FROM " . $wpdb->prefix . "region_tax WHERE id='" . $_SESSION['selected_region'] . "'"); //foreach ($state_name as $state) $tax_rule->SetStateAreas(array($state_name)); } else { $tax_rule->AddPostalArea(get_option('base_country')); } $google_cart->AddDefaultTaxRules($tax_rule); $alter_tax_rule = new GoogleDefaultTaxRule(0.0); foreach ((array) $google_shipping_country as $country) { if (get_option('base_country') != $country['isocode']) { $alter_tax_rule->AddPostalArea($country['isocode']); } } if ($alter_tax_rule != '') { $google_cart->AddDefaultTaxRules($alter_tax_rule); } } $output .= "<span class='emptycart'><a href='" . get_option('product_list_url') . $seperator . "category=" . $_GET['category'] . "&cart=empty' onclick='emptycart();return false;'>" . TXT_WPSC_EMPTYYOURCART . "</a><span>"; $output .= "<span class='gocheckout'><a href='" . get_option('shopping_cart_url') . "'>" . TXT_WPSC_GOTOCHECKOUT . "</a></span>"; if (get_option('payment_gateway') == 'google') { if (get_option('google_button_size') == '0') { $google_button_size = 'BIG'; } elseif (get_option('google_button_size') == '1') { $google_button_size = 'MEDIUM'; } elseif (get_option('google_button_size') == '2') { $google_button_size = 'SMALL'; } $google_cart->SetMerchantCalculations(get_option('siteurl'), "false", "false"); $google_cart->SetRequestBuyerPhone("true"); $google_session = md5(time()); $_SESSION['google_session'] = $google_session; if (!preg_match("/\\?/", get_option('product_list_url'))) { $seperator = "?"; } else { $seperator = "&"; } $continueshoppingurl = get_option('product_list_url') . $seperator . "action=bfg&session=" . $google_session; $google_cart->SetContinueShoppingUrl($continueshoppingurl); $google_cart->SetEditCartUrl(get_option('shopping_cart_url')); $_SESSION['google_shopping_cart'] = serialize($google_cart); // $output .= $google_cart->getXML(); $output .= "<br>" . $google_cart->CheckoutButtonCode($google_button_size); } //$output .= "<a href='".get_option('product_list_url')."'>".TXT_WPSC_CONTINUESHOPPING."</a>"; } else { $output .= $spacing; $output .= "<p class='empty'>" . TXT_WPSC_YOURSHOPPINGCARTISEMPTY . ".</p>"; $output .= "<p class='visitshop'><a href='" . get_option('product_list_url') . "'>" . TXT_WPSC_VISITTHESHOP . "</a></p>"; } $output .= "</div>"; return $output; }