x
 
Create New Page
 View Previous Changes    ( Last updated by Lisa Wess )

Simple Commerce with PayPal Option Fields

This may or may not be fixed in the latest Simple Commerce release, but it doesn’t work in mine (1.6.0, I think), so I thought I’d post how to fix it.

I provided my own variables to PayPal (see Advanced PayPal), and I used the on0/os0 and on1/os1 fields.  When I created my admin email template the variables {option_selection1} etc. worked fine on the Buy Now button, but didn’t work on the Add to Cart button.  PayPal had the data, but it wasn’t showing up in the email.  So I dug through the php file, and I found out why.  I added this in the perform_actions function, where they were setting $this->post[‘item_name’] and other variables:

if ($num_in_cart != '')
        
{
            
if ( isset($_POST['option_name1_'.$num_in_cart]))
            
{
                $this
->post['option_name1'] = $_POST['option_name1_'.$num_in_cart];
            
}

            
if ( isset($_POST['option_selection1_'.$num_in_cart]))
            
{
                $this
->post['option_selection1'] = $_POST['option_selection1_'.$num_in_cart];
            
}

            
if ( isset($_POST['option_name2_'.$num_in_cart]))
            
{
                $this
->post['option_name2'] = $_POST['option_name2_'.$num_in_cart];
            
}

            
if ( isset($_POST['option_selection2_'.$num_in_cart]))
            
{
                $this
->post['option_selection2'] = $_POST['option_selection2_'.$num_in_cart];
            
}
        }

Interestingly, the module current resets the item_name to the one received from the query, not the one in the return from PayPal.  If you, like me, modify the name before sending it to PayPal (because you, like me, had more then two options to send, and PayPal only gives you two), this is not good.  But if you comment out their line then add this to the above code block, you get the appropriate item_name:

if ( isset($_POST['item_name'.$num_in_cart]))
            
{
                $this
->post['item_name'] = $_POST['item_name'.$num_in_cart];
            
}

Use at your own risk, etc., etc., etc.

Category:Commerce -> PayPal Category:Hacks

Categories: