Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length


VirtueMart 1.1.5 - [SECURITY RELEASE] is available! Read more....

  Advanced search

216594 Posts in 58326 Topics- by 87995 Members - Latest Member: duane9melton
Pages: [1] 2   Go Down
Print
Author Topic: How to have full item listing detailled in Paypal Cart !  (Read 9543 times)
Axel
Newbie
*
Posts: 4


View Profile
« on: October 26, 2006, 16:53:21 pm »

Here's the code I use i n order to have all items listed in the cart. It allows to have a fully described cart on many lines, and no more only one line with the total amount.

tax & tax_cart are both defined. I think only tax_cart is enough, I didn't take time to check that.
Off course, adapt the code to fit your needs!

I think it would be great if this code would be insert in a wiki or examples, or doc.


Code:
<?php
//"item_name" => $VM_LANG->_PHPSHOP_ORDER_PRINT_PO_NUMBER.": ". $db->f("order_id")
$order_id $db->f("order_id");
$dboi = new ps_DB;
$q_oi "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);
$description "Inscriptions";
$row_num $dboi->num_rows();
$i=1;
while(
$dboi->next_record()) {
    
    
$supp_var['item_name_' $i] = $dboi->f("order_item_name");
    
$supp_var['quantity_' $i] = $dboi->f("product_quantity");
    
$supp_var['amount_' $i] = round($dboi->f("product_item_price"),2);
    
$i++;
}


$dbb = new ps_DB;
$q "SELECT * FROM jos_vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();
/*
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",

*/

$url "https://www.sandbox.paypal.com/cgi-bin/webscr";
$tax_total round($db->f("order_tax") + $db->f("order_shipping_tax"),2);
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_cart",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"item_name" => $description,
"currency_code" => $_SESSION['vendor_currency'],
"amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
"tax" => $tax_total,
"tax_cart" => $tax_total,
"receiver_email" => PAYPAL_EMAIL,
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"shipping" => sprintf("%.2f"$db->f("order_shipping")),
"image_url" => $vendor_image_url,
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"undefined_quantity" => "0",
"test_ipn" => PAYPAL_DEBUG,
"pal" => "NRUBJXESJTY24",
"no_shipping" => "1",
"no_note" => "0",

"email" => $dbb->f("user_email"),
"first_name" => $dbb->f("first_name"),
"last_name" => $dbb->f("last_name"),
"address1" => $dbb->f("address_1"),
"address2" => $dbb->f("address_2"),
"city" => $dbb->f("city"),
"state" => $dbb->f("state"),
"zip" => $dbb->f("zip"),
"H_PhoneNumber" => $dbb->f("phone_1")
);
if( 
$page == "checkout.thankyou" ) {
$query_string "?";

foreach( 
$post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
}
if(
is_array($supp_var) && count($supp_var)) {
foreach($supp_var as $name => $value) {
$query_string .= $name"=" urlencode($value) ."&";
}
}


mosRedirect$url $query_string );
} else {

echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';


foreach( 
$post_variables as $name => $value ) {
echo 
'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}

if(
is_array($supp_var) && count($supp_var)) {
foreach($supp_var as $name => $value) {
echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}
}

echo 
'</form>';

}
?>


Feel free to make any suggestions!
Axel
Logged
macallf
Hero Member
*****
Posts: 2419



View Profile WWW
« Reply #1 on: October 26, 2006, 17:15:12 pm »

Fair enough Axel

BUT. You have posted this in three different boards and have not mentioned which file you have edited!!!

Once is enough and more details on what you have modified, added etc

Mark
Logged

Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.
Axel
Newbie
*
Posts: 4


View Profile
« Reply #2 on: October 26, 2006, 18:58:43 pm »

I didn't modifiyed any file, this is the code to paste in the configuration section of Paypal payment method.

Sorry for cross-posts, but there are many sections with deals with almost the same subject.

Please tell me which section is the most suitable for this , and I ll delete the others topics.
Thanks
Logged
N6REJ
Sr. Member
****
Posts: 295

Beauty By Design


View Profile WWW
« Reply #3 on: December 08, 2006, 12:29:29 pm »

be sure to replace "sandbox" url with.. https://www.paypal.com/cgi-bin/webscr or it won't work.
Logged

Troy
http://www.treeturner.com
Beauty by Design
strikeitup
Newbie
*
Posts: 7


View Profile
« Reply #4 on: December 11, 2006, 09:28:27 am »

Thanks Axel!

Works great, but unfortunately the shipping is not being calculated for me on the PayPal page. I checked the query string and the shipping is there (ie. shipping=5.00).

This probably isn't the best practice for fixing the problem, but I am simply pushing a "Shipping" item to the item array on line 18 below. Also grabbing the shipper and rate description while I'm at it:

Code:
<?php
//"item_name" => $VM_LANG->_PHPSHOP_ORDER_PRINT_PO_NUMBER.": ". $db->f("order_id")
$order_id $db->f("order_id");
$dboi = new ps_DB;
$q_oi "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);
$description "Inscriptions";
$row_num $dboi->num_rows();
$i=1;
while(
$dboi->next_record()) {
    
$supp_var['item_name_' $i] = $dboi->f("order_item_name");
    
$supp_var['quantity_' $i] = $dboi->f("product_quantity");
    
$supp_var['amount_' $i] = round($dboi->f("product_item_price"),2);
    
$i++;
}

//Fix to add shipping as item:
$dbsi = new ps_DB;
$q_si "SELECT ship_method_id FROM #__vm_orders ";
$q_si .= "WHERE #__vm_orders.order_id='$order_id'";
$dbsi->query($q_si);
$shipInfo split("\|"$dbsi->f("ship_method_id"));
$supp_var['item_name_' $i] = "Shipping - " $shipInfo[1] . " - " $shipInfo[2];
$supp_var['quantity_' $i] = "1";
$supp_var['amount_' $i] = sprintf("%.2f"$db->f("order_shipping"));
//End Ship Fix

$dbb = new ps_DB;
$q "SELECT * FROM jos_vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();
/*
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",

*/

$url "https://www.paypal.com/cgi-bin/webscr";
$tax_total round($db->f("order_tax") + $db->f("order_shipping_tax"),2);
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_cart",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"item_name" => $description,
"currency_code" => $_SESSION['vendor_currency'],
"amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
"tax" => $tax_total,
"tax_cart" => $tax_total,
"receiver_email" => PAYPAL_EMAIL,
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"shipping" => sprintf("%.2f"$db->f("order_shipping")),
"image_url" => $vendor_image_url,
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"undefined_quantity" => "0",
"test_ipn" => PAYPAL_DEBUG,
"pal" => "NRUBJXESJTY24",
"no_shipping" => "1",
"no_note" => "0",

"email" => $dbb->f("user_email"),
"first_name" => $dbb->f("first_name"),
"last_name" => $dbb->f("last_name"),
"address1" => $dbb->f("address_1"),
"address2" => $dbb->f("address_2"),
"city" => $dbb->f("city"),
"state" => $dbb->f("state"),
"zip" => $dbb->f("zip"),
"H_PhoneNumber" => $dbb->f("phone_1")
);
if( 
$page == "checkout.thankyou" ) {
$query_string "?";

foreach( 
$post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
}
if(
is_array($supp_var) && count($supp_var)) {
foreach($supp_var as $name => $value) {
$query_string .= $name"=" urlencode($value) ."&";
}
}


mosRedirect$url $query_string );
} else {

echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';


foreach( 
$post_variables as $name => $value ) {
echo 
'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}

if(
is_array($supp_var) && count($supp_var)) {
foreach($supp_var as $name => $value) {
echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}
}

echo 
'</form>';

}
?>


On the detailed PayPal view this will display something like,

ItemOptionsQuantityAmount
Metal Ladder 1$79.99 USD
Shipping - UPS - Next Day Air Saver1$45.00 USD
Subtotal:$124.99 USD
Sales Tax: $4.80 USD
Total Amount: $129.79 USD


I just had to come up with a fix ASAP as my client is getting a lot of xMas orders.

Preferably, the shipping would show after the subtotal, and I think this may be what you intended Axel, or perhaps this problem is isoolated to my environment?

If anyone has a better solution, ie. getting shipping to show up on PayPal screen as another line below the item list and before / with the total please comment.

Thanks!
« Last Edit: December 11, 2006, 09:31:32 am by strikeitup » Logged
Douglas Kirkpatrick
Newbie
*
Posts: 10


View Profile
« Reply #5 on: December 13, 2006, 11:26:49 am »

Hi

This is exactly what my client needs but as this is my very first virtuemart install and i'm only a couple of completed ecommerce into this arena i need a little more explanation.

The standard code works fine in my install but it only gives the total in Paypal (still in the sandbox).

For this code to work am i right in thinking that i need to setup a database field specifically to hold the order info that i need to or should it all be working automatically?

I'm also working in the UK so would this make the parameters for paypal differnet in some way?

Thanks for reading guys - i'll continue to muddle through this issue for now but a bit of clarity would help a lot.
Logged
kane357
Full Member
***
Posts: 125


View Profile WWW
« Reply #6 on: March 23, 2007, 20:21:35 pm »

Is this module still working fine after so many updates/
Logged

Joomla! 1.5.3
VM 1.1
baze
Newbie
*
Posts: 1


View Profile
« Reply #7 on: March 25, 2007, 03:23:57 am »

I tried strikeitup's code, and it works for the most part.  However, coupons do not register.

Just a note of caution....
Logged
Tim
Newbie
*
Posts: 1


View Profile
« Reply #8 on: March 28, 2007, 22:06:32 pm »

Great code. Now my customer don't see "you ordered ID #..." They can now see what they ordered. Does anyone know how to make the coupon work with this script?
Logged
Rodrigo Fernandez
Newbie
*
Posts: 10


View Profile
« Reply #9 on: June 30, 2007, 02:35:35 am »

It works great for showing all the item descriptions in PayPal, but it does not show the "Shipping and Handling Fees"  Smiley

How can I make it show "Shipping and Handling Fees" like the default code does?
Logged
Rodrigo Fernandez
Newbie
*
Posts: 10


View Profile
« Reply #10 on: June 30, 2007, 02:45:05 am »

This one works great also, and it does show the shipping:
http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=26537.0
Logged
kane357
Full Member
***
Posts: 125


View Profile WWW
« Reply #11 on: August 23, 2007, 07:42:32 am »

how do you get the order number onto paypal cart. I have many thousands of orders and when i need to refund its very hard. For instance, I have customers who have business names , i have to sort by date and etc... then i have to check the name of hte prodcut / price and sometimes i have multiple products on the same day.
Logged

Joomla! 1.5.3
VM 1.1
superchump
Newbie
*
Posts: 1


View Profile
« Reply #12 on: January 15, 2008, 19:40:37 pm »

I appreciate all this info...it's where I'm having issues as well.

The problem is, that when I paste that code into the Paypal Extra Info box and save it, then go back, it has chopped off quite a bit of the code....which causes it to display incorrectly.

Any ideas?
Logged
Anthony G
Jr. Member
**
Posts: 74


View Profile WWW
« Reply #13 on: January 19, 2008, 02:26:53 am »

the subtotals are not transfering... anyone have any ideas?
Logged

Mark Wass
Newbie
*
Posts: 9


View Profile
« Reply #14 on: February 20, 2008, 02:20:06 am »

Thanks Axel!

Works great, but unfortunately the shipping is not being calculated for me on the PayPal page. I checked the query string and the shipping is there (ie. shipping=5.00).

This probably isn't the best practice for fixing the problem, but I am simply pushing a "Shipping" item to the item array on line 18 below. Also grabbing the shipper and rate description while I'm at it:

Code:
<?php
//"item_name" => $VM_LANG->_PHPSHOP_ORDER_PRINT_PO_NUMBER.": ". $db->f("order_id")
$order_id $db->f("order_id");
$dboi = new ps_DB;
$q_oi "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);
$description "Inscriptions";
$row_num $dboi->num_rows();
$i=1;
while(
$dboi->next_record()) {
    
$supp_var['item_name_' $i] = $dboi->f("order_item_name");
    
$supp_var['quantity_' $i] = $dboi->f("product_quantity");
    
$supp_var['amount_' $i] = round($dboi->f("product_item_price"),2);
    
$i++;
}

//Fix to add shipping as item:
$dbsi = new ps_DB;
$q_si "SELECT ship_method_id FROM #__vm_orders ";
$q_si .= "WHERE #__vm_orders.order_id='$order_id'";
$dbsi->query($q_si);
$shipInfo split("\|"$dbsi->f("ship_method_id"));
$supp_var['item_name_' $i] = "Shipping - " $shipInfo[1] . " - " $shipInfo[2];
$supp_var['quantity_' $i] = "1";
$supp_var['amount_' $i] = sprintf("%.2f"$db->f("order_shipping"));
//End Ship Fix

$dbb = new ps_DB;
$q "SELECT * FROM jos_vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();
/*
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",

*/

$url "https://www.paypal.com/cgi-bin/webscr";
$tax_total round($db->f("order_tax") + $db->f("order_shipping_tax"),2);
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_cart",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"item_name" => $description,
"currency_code" => $_SESSION['vendor_currency'],
"amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
"tax" => $tax_total,
"tax_cart" => $tax_total,
"receiver_email" => PAYPAL_EMAIL,
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"shipping" => sprintf("%.2f"$db->f("order_shipping")),
"image_url" => $vendor_image_url,
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"undefined_quantity" => "0",
"test_ipn" => PAYPAL_DEBUG,
"pal" => "NRUBJXESJTY24",
"no_shipping" => "1",
"no_note" => "0",

"email" => $dbb->f("user_email"),
"first_name" => $dbb->f("first_name"),
"last_name" => $dbb->f("last_name"),
"address1" => $dbb->f("address_1"),
"address2" => $dbb->f("address_2"),
"city" => $dbb->f("city"),
"state" => $dbb->f("state"),
"zip" => $dbb->f("zip"),
"H_PhoneNumber" => $dbb->f("phone_1")
);
if( 
$page == "checkout.thankyou" ) {
$query_string "?";

foreach( 
$post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
}
if(
is_array($supp_var) && count($supp_var)) {
foreach($supp_var as $name => $value) {
$query_string .= $name"=" urlencode($value) ."&";
}
}


mosRedirect$url $query_string );
} else {

echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';


foreach( 
$post_variables as $name => $value ) {
echo 
'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}

if(
is_array($supp_var) && count($supp_var)) {
foreach($supp_var as $name => $value) {
echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}
}

echo 
'</form>';

}
?>


On the detailed PayPal view this will display something like,

ItemOptionsQuantityAmount
Metal Ladder 1$79.99 USD
Shipping - UPS - Next Day Air Saver1$45.00 USD
Subtotal:$124.99 USD
Sales Tax: $4.80 USD
Total Amount: $129.79 USD


I just had to come up with a fix ASAP as my client is getting a lot of xMas orders.

Preferably, the shipping would show after the subtotal, and I think this may be what you intended Axel, or perhaps this problem is isoolated to my environment?

If anyone has a better solution, ie. getting shipping to show up on PayPal screen as another line below the item list and before / with the total please comment.

Thanks!

Thanks for this solution, but when my clients return to my store from PayPal they are simply taken to the front page of my store. Why is it not going to the thank you page?

Could someone please point out why this is not going to the thank you page. The defualt PayPal setup works great it does send them to the Thank you page.

Thanks for your input.
« Last Edit: February 20, 2008, 03:29:50 am by Mark Wass » Logged
Pages: [1] 2   Go Up
Print
Jump to: