Post
by cm » Tue Oct 13, 2009 1:11 am
Hello,
I am experimenting with PayPal buttons in a WebYep Loop-Element. The user should be able to add products (name, product photo, description and price). When pushing the "Add to cart" button, the product name and the price are placed in the cart. It's not perfect, but seems to be working already. Maybe You find it useful or maybe someone has an idea how to make it better.
<?php // ><!--
$webyep_sIncludePath = "./";
$iDepth = 0;
while (!file_exists($webyep_sIncludePath . "webyep-system")) {
$iDepth++;
if ($iDepth > 10) {
error_log("webyep-system folder not found.", 0);
break;
}
$webyep_sIncludePath = ($webyep_sIncludePath == "./") ? ("../"):("$webyep_sIncludePath../");
}
if (file_exists("$webyep_sIncludePath/webyep-system/programm")) $webyep_sIncludePath .= "webyep-system/programm";
else $webyep_sIncludePath .= "webyep-system/program";
$sMain = "$webyep_sIncludePath/webyep.php";
if (file_exists($sMain)) include($sMain);
// --> <dummy ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<?php foreach (WYLoopElement::aLoopIDs("ProductsLoop") as $webyep_oCurrentLoop->iLoopID) { $webyep_oCurrentLoop->loopStart(true); ?>
<h3>
Product Name:<?php webyep_shortText("Name", false); ?>
</h3>
<?php webyep_image("Product_Photo", false, '', '', '', 120, 100, true); ?>
<br />
Description: <?php webyep_richText("Description", false, "", true); ?>
<br />
Price: <?php webyep_shortText("Price", false); ?>
<br />
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="YourPaypalAccount@xyz.com">
<input type="hidden" name="item_name" value="<?php echo webyep_sShortTextContent("Name", false); ?>">
<input type="hidden" name="item_number" value="id1">
<input type="hidden" name="amount" value="<?php echo webyep_sShortTextContent("Price", false); ?>">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="EUR">
<input type="submit" name="submit" value="Add to cart">
</form>
<br />
<?php $webyep_oCurrentLoop->loopEnd(); } ?>
<?php webyep_logonButton(true); ?>
</body>
</html>