Jump to content

osCommerce China

Members
  • Content count

    11
  • Joined

  • Last visited

3 Followers

Profile Information

  • Real Name
    Lin Yang
  1. osCommerce China

    Oscommerce 2.3 - PayPal Express Postage Charges

    while (true) { if (isset($HTTP_POST_VARS['L_NUMBER' . $counter])) { if(is_numeric($HTTP_POST_VARS['L_NUMBER' . $counter])){ $cart->add_cart($HTTP_POST_VARS['L_NUMBER' . $counter], $HTTP_POST_VARS['L_QTY' . $counter]); } else{ $attributes = array(); $products_str = explode('{',$HTTP_POST_VARS['L_NUMBER' . $counter]); //get how many attrib $product_id = (int)$products_str[0]; for($i=1; $i<sizeof($products_str); $i++){ //0 is products_id $attr_value= explode('}', $products_str[$i]); //separate key and value $attributes[$attr_value[0]] = $attr_value[1]; } $cart->add_cart($product_id, $HTTP_POST_VARS['L_QTY' . $counter], $attributes); } } else { break; } $counter++; }
  2. osCommerce China

    Oscommerce 2.3 - PayPal Express Postage Charges

    Now I have make sure, there is a bug in ext/modules/payment/paypal/express.php if (isset($HTTP_POST_VARS['L_NUMBER' . $counter])) { $cart->add_cart($HTTP_POST_VARS['L_NUMBER' . $counter], $HTTP_POST_VARS['L_QTY' . $counter]); } if products have attribute the way $cart->add_cart('138{1}3',1) will return add card faild and cart number is 0 that exit and can not get the right shipping fee the right way is while (true) { if (isset($HTTP_POST_VARS['L_NUMBER' . $counter])) { //$cart->add_cart($HTTP_POST_VARS['L_NUMBER' . $counter], $HTTP_POST_VARS['L_QTY' . $counter]); if(is_numeric($HTTP_POST_VARS['L_NUMBER' . $counter])){ $cart->add_cart($HTTP_POST_VARS['L_NUMBER' . $counter], $HTTP_POST_VARS['L_QTY' . $counter]); } else{ $product_id = ''; $products = explode('{', $HTTP_POST_VARS['L_NUMBER' . $counter]); $product_id = (int)$products[0]; $attributes = array(); for($i=1; $i<sizeof($products); $i++){ $attributes_str = explode('}', $products[$i]); $attributes[$attributes_str[0]]=$attributes_str[1]; } $cart->add_cart($product_id, $HTTP_POST_VARS['L_QTY' . $counter], $attributes); } } else { break; } $counter++; }
  3. osCommerce China

    Oscommerce 2.3 - PayPal Express Postage Charges

    I have check and test debug infomation one day. now the shipping fee is ok. 1: you site must have ssl 2: The session setting will influence the paypal get the shipping fee. osCommerce send products id to paypal and paypal imitate add products to cart Force Cookie Use must off. if this on the $cart->count_contents() is 0 and exit, will not return shipping fee. case 'callbackSet': if (MODULE_PAYMENT_PAYPAL_EXPRESS_INSTANT_UPDATE == 'True') { $counter = 0; while (true) { if (isset($HTTP_POST_VARS['L_NUMBER' . $counter])) { $cart->add_cart($HTTP_POST_VARS['L_NUMBER' . $counter], $HTTP_POST_VARS['L_QTY' . $counter]); } else { break; } $counter++; } //debug $fp = fopen("express_".date("Y-m-d-h-i").".txt","a"); flock($fp, LOCK_EX) ; fwrite($fp,"time: ".date("Y-m-d h:i:s")."\r\n"); flock($fp, LOCK_EX) ; ob_start(); print_r($_POST); print_r($cart); $cache_output = ob_get_contents(); ob_end_clean(); fwrite($fp,$cache_output."\r\nCart: ".$cart->count_contents()."\r\n"); flock($fp, LOCK_UN); fclose($fp); //debug // exit if there is nothing in the shopping cart if ($cart->count_contents() < 1) { exit; } if($HTTP_POST_VARS['SHIPTOCOUNTRY']=='C2'){ $HTTP_POST_VARS['SHIPTOCOUNTRY'] ='CN'; } $sendto = array('firstname' => '', 'lastname' => '', 'company' => '', 'street_address' => '', 'suburb' => '', 'postcode' => $HTTP_POST_VARS['SHIPTOZIP'], 'city' => $HTTP_POST_VARS['SHIPTOCITY'], 'zone_id' => '', 'zone_name' => $HTTP_POST_VARS['SHIPTOSTATE'], 'country_id' => '', 'country_name' => $HTTP_POST_VARS['SHIPTOCOUNTRY'], 'country_iso_code_2' => '', 'country_iso_code_3' => '', 'address_format_id' => ''); $country_query = tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . tep_db_input($sendto['country_name']) . "' limit 1"); if (tep_db_num_rows($country_query)) { $country = tep_db_fetch_array($country_query); $sendto['country_id'] = $country['countries_id']; $sendto['country_name'] = $country['countries_name']; $sendto['country_iso_code_2'] = $country['countries_iso_code_2']; $sendto['country_iso_code_3'] = $country['countries_iso_code_3']; $sendto['address_format_id'] = $country['address_format_id']; } if ($sendto['country_id'] > 0) { $zone_query = tep_db_query("select * from " . TABLE_ZONES . " where zone_country_id = '" . (int)$sendto['country_id'] . "' and (zone_name = '" . tep_db_input($sendto['zone_name']) . "' or zone_code = '" . tep_db_input($sendto['zone_name']) . "') limit 1"); if (tep_db_num_rows($zone_query)) { $zone = tep_db_fetch_array($zone_query); $sendto['zone_id'] = $zone['zone_id']; $sendto['zone_name'] = $zone['zone_name']; } } $billto = $sendto; $quotes_array = array(); include(DIR_WS_CLASSES . 'order.php'); if ($cart->get_content_type() != 'virtual') { $order = new order; $total_weight = $cart->show_weight(); $total_count = $cart->count_contents(); // load all enabled shipping modules include(DIR_WS_CLASSES . 'shipping.php'); $shipping_modules = new shipping; $free_shipping = false; if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) { $pass = false; switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { case 'national': if ($order->delivery['country_id'] == STORE_COUNTRY) { $pass = true; } break; case 'international': if ($order->delivery['country_id'] != STORE_COUNTRY) { $pass = true; } break; case 'both': $pass = true; break; } if ( ($pass == true) && ($order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) { $free_shipping = true; include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php'); } } if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) { if ($free_shipping == true) { $quotes_array[] = array('id' => 'free_free', 'name' => FREE_SHIPPING_TITLE, 'label' => FREE_SHIPPING_TITLE, 'cost' => '0', 'tax' => '0'); } else { // get all available shipping quotes $quotes = $shipping_modules->quote(); foreach ($quotes as $quote) { if (!isset($quote['error'])) { foreach ($quote['methods'] as $rate) { $quotes_array[] = array('id' => $quote['id'] . '_' . $rate['id'], 'name' => $quote['module'], 'label' => $rate['title'], 'cost' => $rate['cost'], 'tax' => isset($quote['tax']) ? $quote['tax'] : '0'); } } } } } } else { $quotes_array[] = array('id' => 'null', 'name' => 'No Shipping', 'label' => 'No Shipping', 'cost' => '0', 'tax' => '0'); } $params = array('METHOD' => 'CallbackResponse', 'OFFERINSURANCEOPTION' => 'false'); $counter = 0; $cheapest_rate = null; $cheapest_counter = $counter; foreach ($quotes_array as $quote) { $shipping_rate = $paypal_express->format_raw($quote['cost'] + tep_calculate_tax($quote['cost'], $quote['tax'])); $params['L_SHIPPINGOPTIONNAME' . $counter] = $quote['name']; $params['L_SHIPINGPOPTIONLABEL' . $counter] = '(' . strip_tags($quote['label']) . ')'; $params['L_SHIPPINGOPTIONAMOUNT' . $counter] = $paypal_express->format_raw($quote['cost']); $params['L_SHIPPINGOPTIONISDEFAULT' . $counter] = 'false'; $params['L_TAXAMT' . $counter] = $paypal_express->format_raw($order->info['tax'] + tep_calculate_tax($quote['cost'], $quote['tax'])); if (is_null($cheapest_rate) || ($shipping_rate < $cheapest_rate)) { $cheapest_rate = $shipping_rate; $cheapest_counter = $counter; } $counter++; } $params['L_SHIPPINGOPTIONISDEFAULT' . $cheapest_counter] = 'true'; $post_string = ''; foreach ($params as $key => $value) { $post_string .= $key . '=' . urlencode(utf8_encode(trim($value))) . '&'; } $post_string = substr($post_string, 0, -1); echo $post_string; } //debug $fp = fopen("express_".date("Y-m-d-h-i").".txt","a+"); fwrite($fp, $post_string."\r\n"); flock($fp, LOCK_UN); fclose($fp); //debug exit; break; 3. if products with attribute the add cart faild. time: 2012-09-19 11:42:06 Array ( [METHOD] => CallbackRequest [CALLBACKVERSION] => 57 [TOKEN] => EC-5Y926703UH5421842 [LOCALECODE] => en_US [CURRENCYCODE] => USD [L_NAME0] => iPod Classic [L_NUMBER0] => 138{1}3 [L_DESC0] => [L_AMT0] => 89.00 [L_QTY0] => 1 [L_ITEMWEIGHTUNIT0] => [L_ITEMWEIGHTVALUE0] => 0 [L_ITEMHEIGHTUNIT0] => [L_ITEMHEIGHTVALUE0] => 0 [L_ITEMWIDTHUNIT0] => [L_ITEMWIDTHVALUE0] => 0 [L_ITEMLENGTHUNIT0] => [L_ITEMLENGTHVALUE0] => 0 [sHIPTOSTREET] => 5041Heintz St [sHIPTOCITY] => Baldwin Park [sHIPTOSTATE] => CA [sHIPTOCOUNTRY] => US [sHIPTOZIP] => 91706 [sHIPTOSTREET2] => Baldwin ) shoppingCart Object ( [contents] => Array ( ) [total] => 0 [weight] => 0 [content_type] => ) Cart: 0 is a bug ?
  4. osCommerce China

    Oscommerce 2.3 - PayPal Express Postage Charges

    I have also use word zone shipping rate. and also can not update shipping fee in paypal my server is a full ssl host follow is my debug info of ext/modules/payment/paypal/express.php POST Array ( [METHOD] => CallbackRequest [CALLBACKVERSION] => 57 [TOKEN] => EC-7J889120M1357080F [LOCALECODE] => en_US [CURRENCYCODE] => USD [L_NAME0] => iPod Touch 10 [L_NUMBER0] => 148 [L_DESC0] => [L_AMT0] => 99.00 [L_QTY0] => 3 [L_ITEMWEIGHTUNIT0] => [L_ITEMWEIGHTVALUE0] => 0 [L_ITEMHEIGHTUNIT0] => [L_ITEMHEIGHTVALUE0] => 0 [L_ITEMWIDTHUNIT0] => [L_ITEMWIDTHVALUE0] => 0 [L_ITEMLENGTHUNIT0] => [L_ITEMLENGTHVALUE0] => 0 [sHIPTOSTREET] => SouthHuanghe Road 22 [sHIPTOCITY] => zhuzhou [sHIPTOSTATE] => Hunan [sHIPTOCOUNTRY] => CN [sHIPTOZIP] => 412007 [sHIPTOSTREET2] => ) GET Array ( [osC_Action] => callbackSet ) the $params array before the line 221 echo $post_string; Array ( [METHOD] => CallbackResponse [OFFERINSURANCEOPTION] => false [L_SHIPPINGOPTIONNAME0] => Per Item (Best Way) [L_SHIPINGPOPTIONLABEL0] => [L_SHIPPINGOPTIONAMOUNT0] => 2.50 [L_SHIPPINGOPTIONISDEFAULT0] => true [L_TAXAMT0] => 0.00 [L_SHIPPINGOPTIONNAME1] => World Express (Shipping to China 7-15 Days) [L_SHIPINGPOPTIONLABEL1] => [L_SHIPPINGOPTIONAMOUNT1] => 40.00 [L_SHIPPINGOPTIONISDEFAULT1] => false [L_TAXAMT1] => 0.00 [L_SHIPPINGOPTIONNAME2] => Express (Shipping to China 7-15 Days) [L_SHIPINGPOPTIONLABEL2] => [L_SHIPPINGOPTIONAMOUNT2] => 8.50 [L_SHIPPINGOPTIONISDEFAULT2] => false [L_TAXAMT2] => 0.00 [L_SHIPPINGOPTIONNAME3] => Flat Shipping (Best Way) [L_SHIPINGPOPTIONLABEL3] => [L_SHIPPINGOPTIONAMOUNT3] => 5.00 [L_SHIPPINGOPTIONISDEFAULT3] => false [L_TAXAMT3] => 0.00 ) look like all $params is right. but in the paypal not update the shipping price list when i login paypal when i change shippping country.
  5. I Think There is a logical error on process paypal payment. File:paypal_standard.php When a user create a order and check confirm order. There is a pre order create in database and then go to paypal. When this user back and change his shipping address or billing address and then process order again. the order id is the same and the shipping and billing address not change. Let look the code function pre_confirmation_check() { global $cartID, $cart; if (empty($cart->cartID)) { $cartID = $cart->cartID = $cart->generate_cart_id(); } if (!tep_session_is_registered('cartID')) { tep_session_register('cartID'); } } only there is no cartID will create a new card id. or modify the shipping cart the new card will create. but in the order process function if the $cartID is exit and $cart_PayPal_Standard_ID exit. the order is in datebase function confirmation() { ....... if (tep_db_num_rows($check_query) < 1) { delete order ..... is have order and will not remove old order infomation so the shippping address and billing address will not update.
×