Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Maybe Help for someone try and import this code to


baesic2

Recommended Posts

I may be way out of line here I am just getting involved with osCommerce, I may have even crossposted a feww time I am trying not to do that any longer. But somtimes I feel a topic belongs in a couple different areas of the forum. For the mistakes I apologize to each forum member.

 

However I have a store running now in html format, that I can change the options loaded into paypal, so when the information is passed to paypal. That information is viewable in the paypal where you can then ship from paypal account.

 

My question here is? I have oscommerce 2.2 MS2 and the offical oscommerce_PayPal _IPN which up to this point just learned that you can only pass two variables through to the paypal account the rest of the variables do not show up

 

I am loading the code in which I pass the information through to paypal, I am only trying to maybe assist in making more attributes show up in paypal and I also have no idea about implementing these changes. But it might help someone possibly and possibly not.

 

 

Copy and paste into html document for full html instuctions.

on how this works. I do not know if in could be incorporated into OSC PAYPAL IPN

to pass on variable information. Thanks for your time and I hope I did not waste anyone time. But this works great in html format use it if you like it.

 

Copy Below

 

<script type="text/javascript">

<!--

function Dollar (val) { // force to valid dollar amount

var str,pos,rnd=0;

if (val < .995) rnd = 1; // for old Netscape browsers

str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape

pos = str.indexOf (".");

if (pos > 0) str = str.substring (rnd, pos + 3);

return str;

}

 

function ReadForm (obj1) { // process un-named selects

var i,j,amt,des,obj,pos,fst,val,num="";

var ary = new Array ();

amt = obj1.baseamt.value*1.0; // base amount

des = obj1.basedes.value; // base description

for (i=0; i<obj1.length; i++) { // run entire form

obj = obj1.elements; // a form element

if (obj.type == "select-one" && // just get selects

obj.name == "") { // must be un-named

pos = obj.selectedIndex; // which option selected

val = obj.options[pos].value; // selected value

ary = val.split (" "); // break apart

for (j=0; j<ary.length; j++) { // look at all items

// first we do single character tokens...

if (ary[j].length < 2) continue;

fst = ary[j].substring (0,1); // first character

val = ary[j].substring (1); // get data

if (fst == "@") amt = val * 1.0;

if (fst == "+") amt = amt + val*1.0;

if (fst == "%") amt = amt + (amt * val/100.0);

if (fst == "#") { // record item number

num = val;

ary[j] = ""; // zap this array element

}

// Now we do 3-character tokens...

if (ary[j].length < 4) continue;

fst = ary[j].substring (0,3); // first 3 chars

val = ary[j].substring (3); // get data

if (fst == "s1=") { // value for shipping

if (obj1.shipping) obj1.shipping.value = val;

ary[j] = ""; // clear it out

}

if (fst == "s2=") { // value for shipping2

if (obj1.shipping2) obj1.shipping2.value = val;

ary[j] = ""; // clear it out

}

}

val = ary.join (" "); // rebuild val with what's left

if (des.length == 0) des = val; // 1st storage?

else des = des + ", " + val; // nope, accumulate value

}

}

if (obj1.item_number && num.length > 0) obj1.item_number.value = num;

obj1.item_name.value = des;

obj1.amount.value = Dollar (amt);

if (obj1.tot) obj1.tot.value = "$" + Dollar (amt);

}

//-->

</script>

 

</head>

 

<body>

 

<!-- This is the FORM to view the cart contents -->

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="viewcart" name="viewcart">

<p>

<input type="hidden" name="cmd" value="_cart" />

<input type="hidden" name="display" value="1" />

<input type="hidden" name="business" value="[email protected]" />

</p>

</form>

<!-- End of view cart FORM -->

 

<table width="100%">

<tr>

<td>

<h1>Concatenate unnamed selects</h1>

</td>

<td>

<a href = "http://members.aol.com/paypalhelper/">home page</a><br />

<a href = "http://members.aol.com/paypalhelper/stdc.htm">std.css</a>

</td>

</tr>

</table>

 

<p>All this simple JavaScript (JS) plugin does is to accept the <i>value</i>

fields from unnamed selects and concatenate them into the description field.

These <i>value</i> fields may have price modifying information, item numbers or

shipping costs in them.

</p>

 

<p>We start with the output of the PayPal button factory and make a few changes.

Then the JS processes the FORM and adjusts the fields. <view source> on this

page to see what was done.

</p>

 

<ul>

<li>Copy the JS from this example and paste it into your page within the <b>

<head></b> section, like is done on this page. Only one copy of the JS is

needed for any page.</li>

<li>If you want a view-cart button somewhere on the page you must copy the

view FORM from my page and insert it into your page right after the <b>

<body...</b> statement, like I have done here. You will need to change the <i>

business</i> value, or course.</li>

<li>Go into every FORM that can place an order and add these things...

<ul>

<li>A new named element called <i>baseamt</i> to hold the base amount of

the item.</li>

<li>A new named element called <i>basedes</i> to hold the base description

of this item.</li>

<li>An event handler to the to the FORM element, like I have done on this

page.</li>

<li><b>unnamed</b> selects so the user can pick his options.</li>

<li>An optional text field named <i>tot</i> where the item cost is

displayed if you include event handlers on the selects. In this case the

base price must be the default settings of the selects. <view source> to

see how I did it on this page.</li>

</ul></li></ul>

There are single token, and three-token flags that may be used in the <i>value</i>

field of the options.

<ul>

<li>"<b>#</b>" to indicate that an item number follows.</li>

<li>"<b>@</b>" to indicate that a price value follows.</li>

<li>"<b>+</b>" to indicate that a price increment follows.</li>

<li>"<b>%</b>" to indicate that a price percent change follows.</li>

<li>"<b>s1=</b>" indicates a shipping value follows.</li>

<li>"'<b>s2=</b>" indicates a shipping2 value follows.</li>

<li>It is not obvious, but negative amounts are allowed. The first character

is a flag character (has special significance to parsing), but after that

you may input any valid nunmber. -1 is a valid number, so "+-1.50" is

perfectly legal.</li>

</ul>

 

<p>Here is an example of what you may put into the value of an option field of a

select...

</p>

 

<pre>

&ltoption value="Description #A1234 s1=10 s2=8.50 @25.00">...</option>

</pre>

 

<p>Setting shipping is a little tricky, in that if you use it in any value field

of a select, then you must use it in every value field, even if it is set to

zero.

</p>

 

<hr />

 

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"

onsubmit="this.target = 'paypal';

ReadForm (this);">

<p>

<input type="hidden" name="cmd" value="_cart" />

<input type="hidden" name="add" value="1" />

<input type="hidden" name="business" value="[email protected]" />

<input type="hidden" name="item_name" value="" />

<input type="hidden" name="item_number" value="" />

<input type="hidden" name="amount" value="" />

<input type="hidden" name="currency_code" value="USD" />

<input type="hidden" name="lc" value="US" />

 

<input type="hidden" name="shipping" value="10" />

<input type="hidden" name="shipping2" value="20" />

 

<input type="hidden" name="baseamt" value="10.00" />

<input type="hidden" name="basedes" value="Test Item" />

 

[picture] Blah, blah.

<br /><br />

Color -

<select onchange = "ReadForm (this.form);">

<option value="white #1212-w s1=2 s2=1 @9.00">white ($9.00)</option>

<option value="red #1212-r s1=0 s2=0 @10.00">red ($10.00)</option>

<option value="blue #1212-b s1=0 s2=0 @11.00">blue ($11.00)</option>

</select>     Fabric -

<select onchange = "ReadForm (this.form);">

<option value="cotton">cotton</option>

<option value="blend">blend</option>

</select>     Size -

<select onchange = "ReadForm (this.form);">

<option value="Small">Small</option>

<option value="Medium +0.50">Medium (+0.50)</option>

<option value="Large +1.00">Large (+1.00)</option>

</select>

 

<br /><br />Input Quantity >

<input type="text" name="quantity" size="3" value="1" />   Total item

cost >

<input class="nbor" type="text" name="tot" size="8" value="$9.00" />  

<input type="image" src="images/x-click-but22.gif" name="submit" alt="cart add" />

<input type="image" src="images/view_cart.gif" alt="cart view"

onclick="document.forms.viewcart.target = 'paypal';

document.forms.viewcart.submit ();

return false;" />

</p>

</form>

 

<hr />

 

<p>

<a href = "http://validator.w3.org/">

<img class = "w3c"

src = "xhtml11.gif"

alt = "Image: XHTML 1.1 certified!" /></a>

<a href = "http://jigsaw.w3.org/css-validator/">

<img class = "w3c"

src = "vcss.gif"

alt = "Image: CSS2 certified!" /></a>

<a href = "http://www.w3.org/wai/">

<img class = "w3c"

src = "wcag1aa.png"

alt = "Image: Multi-user accessibility!" /></a>

 

<br /><br />

</p>

</body>

</html>

 

End Copy HERE

Thank You In Advance, For Your Assistance

From A Newbie Point Of View...

 

Happiness is Getting OSC Operating to it's fullest potential and

with the help of Contributors and Forum Moderators, we can all do it. Support the cause. Donate to osCommerce.

 

baesic2

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...