Stramm,
I have toiled for a few days now, but I have been unable to produce code that works. I keep getting an error (on the Paypal page) that says, "Your shopping cart is empty" once I click the Pay Now button after confirming the order. I may be way off, but here is what I did. I tried writing a function (see below):function photoshop_add_paypal_data($shop_data, $order_id){
global $CONFIG, $SHOP_CONFIG, $cd_price, $cd_counter, $discount, $shipping_price;
$otime = time();
$picture_total = 0;
foreach ($shop_data as $key => $item_id) {
$pid = $item_id['pid'];
$amount = $item_id['amount'];
if ($item_id['id']=="CD") {
$size = "CD";
$price = $cd_price[1];
} else {
$size = $SHOP_CONFIG[$item_id['id']]['name'];
$price = $SHOP_CONFIG[$item_id['id']]['price'];
//price override
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$item_id['aid']}");
while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);
$picture_total = ($picture_total+$price*$amount);
}
$results = cpg_db_query ("INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`pid`, `quantity`, `price`) VALUES ('$pid', '$amount', '$price')");
}
return $results;
}
I call this function just before the Paypal shopping cart form in photo_shop_checkout, which now looks like this: //pay with paypal
photoshop_add_paypal_data($shop_array, $order_id);
if ($CONFIG['photo_shop_paypal_enable']) {
$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['paypal']}<br>
<form action="{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="item_name_1" value="{$pid[0]}">
<input type="hidden" name="amount_1" value="{$price[0]}">
<input type="hidden" name="quantity_1" value="{$amount[0]}">
<input type="hidden" name="item_name_2" value="{$pid[1]}">
<input type="hidden" name="amount_2" value="{$price[1]}">
<input type="hidden" name="quantity_2" value="{$amount[1]}">
<input type="hidden" name="currency_code" value="{$CONFIG['photo_shop_paypal_currency']}">
<input type="hidden" name="shipping" value="{$shipping_price}">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="{$CONFIG['photo_shop_paypal_image']}" border="0" name="submit" alt="Pay with PayPal OR credit card!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
EOT;
}
I could be doing lots of things wrong, I just don't know what they are or how to fix them. Can you help?
Thanks for your patience with me.
~WesG