www.uburst.com www.uburst.com

"Passing variables to CP pages"

Go back to the LobbyClick here to Go Back to Main ListingClick here to see helpClick here to Search the Forum

General Questions
Forum Type: Public
Moderator: edmunds
Time Zone: EST
Printer Friendly Format
Original Message
 
"Passing variables to CP pages"
Posted by garylane on Aug-22-02 at 01:05 PM (EST)
I'm finding U-Shop a little inflexible on the order-processing side.

I want to pass variables to fields in the form templates. For example, I want the Thank You message to include "order number" and "order value" and I want the Credit Card template to include the "order total".

Alternatively, at the sake of being radical, is there a way I can use the U-shop basket to populate a shopping basket but construct my own order-processing pages with the flexibility I want - and not use U-shop for this part of the transaction?

Click to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents

 Table of Contents

RE: Passing variables to CP pages, Bill Weiner, Aug-23-02, (1)
RE: Passing variables to CP pag, garylane, Aug-23-02, (2)
RE: RE: Passing variables to CP pag, Bill Weiner, Aug-26-02, (3)
"RE: RE: Passing variables to ..., Les, Aug-29-02, (4)
RE: RE: Passing variables to CP pag, Bill Weiner, Aug-30-02, (5)
"RE: RE: Passing variables to ..., Les, Sep-06-02, (6)
RE: RE: Passing variables to CP pag, Bill Weiner, Sep-09-02, (7)
"RE: RE: Passing variables to ..., Les, Sep-09-02, (8)
RE: RE: Passing variables to CP pag, Bill Weiner, Sep-10-02, (9)
"RE: RE: Passing variables to ..., Les, Sep-10-02, (10)

 

 
Click here to goto Click here to goto the Lobby
Messages in this discussion
 
1 . "RE: Passing variables to CP pages"
Posted by Bill Weiner on Aug-23-02 at 04:41 AM (EST)
In regard to adding the order number to the Thank You page, refer to my postings at:

http://www.uburst.com/dcforum/ushop_prog_tips/83.html#2

... for instructions on how to do that.

In regard to the "order value", the order total is already included on the Thank You page. So I'm not sure what you mean there.

In regard to displaying the "order total" on the credit card entry page, at this time that would require making a slight modification of the "display_credit_card_form" subroutine in the ushop-lib.pl script... as per the instructions below:

STEP 1: Make a backup of your ushop-lib.pl script... just in case.

STEP 2: Open your ushop-lib.pl script with any text editor such as WordPad.

STEP 3: Do a search on the following line:

sub display_credit_card_form

(This will get you to the start of the subroutine that displays the credit card entry form.)

STEP 4: About 17 lines down further in that subroutine, locate the following line:

$order_footer = &get_hidden_java_parameters();

STEP 5: Immediately BEFORE that line, add this line:

$order_form_html =~ s/USHOP_TOTAL/$totals_total/g;

STEP 6: Save the script... as TEXT if your editor asks... and try it out as per the instructions below.

The above modification will allow you to add the keyword "USHOP_TOTAL" anywhere on your creditcard_template.html file... and that "USHOP_TOTAL" keyword will be replaced at runtime by the current order total.

Let me know if you have any questions.

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
2 . "RE: Passing variables to CP pag"
Posted by garylane on Aug-23-02 at 08:29 AM (EST)
Thanks a lot for that very constructive advice and the pointer to your other page which will help a lot.

Two follow-up questions:

1) How can I format the numbers output (using the code you suggested I get a 5 decimal place figure (presumably the result of the tax calculations)?

2) One of the problems we're having is caused by the use of the same template for all your main "basket" pages. Based upon your advice in the previous post, I take it that my editing the .pl file, one can replace the field with any HTML we like (including use of variables) to effectively customise these pages far more than is allowed through the control panel.

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
3 . "RE: RE: Passing variables to CP pag"
Posted by Bill Weiner on Aug-26-02 at 04:38 AM (EST)
Glad that information helped. In regard to your follow-ups:

1) You can format the total to two decimal places using code like this:

# Convert total to a number.
$totals_total = &strip_letters($totals_total);

# Format a new total variable.
$formatted_total = sprintf("%s %.2f",$currency_symbol,$totals_total);

2) uShop does use a few templates during the order process that can be customized however you like using just a standard HTML editor:

- The "template_cart.html" page (located in your "classes" directory) allows you to customize the look of the first "Review Cart" page that is displayed after the customer presses the uShopOrderButton applet. Refer to section 7.1.1 in the uShop Users Guide for information about customizing that template. (http://www.uburst.com/uShop/reference/users_guide.html)

- The "order_template.html" file is used to display the order form that the customer fills out on the CGI side of things. Refer to section 9 in the uShop Users Guide for information about customizing that template. (http://www.uburst.com/uShop/reference/users_guide.html)

Otherwise, yes, there are additional ways to customize the uShop CGI scripts themselves to make additional changes... depending on what exactly you would like to do... but for the most part, usually any desired changes can be made directly to the aforementioned template files.

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
4 . ""RE: RE: Passing variables to CP pag""
Posted by Les on Aug-29-02 at 07:54 AM (EST)
Bill, where do you make these changes (what script)in order to display the price as, for example, £39.48, at the moment the price would be something like £39.48250235.

Many thanks in advance for your help.

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
5 . "RE: RE: Passing variables to CP pag"
Posted by Bill Weiner on Aug-30-02 at 04:56 AM (EST)
You would add these lines:

# Convert total to a number.
$totals_total = &strip_letters($totals_total);

# Format a new total variable.
$formatted_total = sprintf("%s %.2f",$currency_symbol,$totals_total);

...directly BEFORE you add the line in STEP 5 of my August 23,2002 posting above.

(Just follow the instructions in my August 23,2002 posting above... and in STEP 5 add the formatting lines before the "$order_form_html =~ s/USHOP_TOTAL/$totals_total/g;" line.)

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
6 . ""RE: RE: Passing variables to CP pag""
Posted by Les on Sep-06-02 at 09:29 AM (EST)
Hi Bill,

I've tries that but it doesn't seem to work, still get 6 digits after the . eg we're still getting things like £109.350006

I copied and pasted the code as you have above.

Any ideas?

Thanks

Les

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
7 . "RE: RE: Passing variables to CP pag"
Posted by Bill Weiner on Sep-09-02 at 06:51 AM (EST)
Exactly when/where in the order process are you seeing the additional digits? The formatting described above would need to be added at that point.
Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
8 . ""RE: RE: Passing variables to CP pag""
Posted by Les on Sep-09-02 at 08:31 AM (EST)
Bill,

I am seeing the extra digits on the credit card page, where the customer enters their credit card details. e.g. we have some text asking the customer to confirm the amount of £xx.xx to be put on their credit card but we get the following £xx.xxxxxxxx

I put the code in where you said but I still get a load of extra digits after the .


It's not any brackets? or any code that has not been displayed that is causing the problem is it, as I think I read on the forum that sometimes certain things don't display as they should.

Regards

Les

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
9 . "RE: RE: Passing variables to CP pag"
Posted by Bill Weiner on Sep-10-02 at 05:05 AM (EST)
Oh, Ok. I understand.

What needs to be done is instead of using "$totals_total" the line:

$order_form_html =~ s/USHOP_TOTAL/$totals_total/g;

We need to use "$formatted_total":

$order_form_html =~ s/USHOP_TOTAL/$formatted_total/g;

So the full set of instructions should look like this:

----------

STEP 1: Make a backup of your ushop-lib.pl script... just in case.

STEP 2: Open your ushop-lib.pl script with any text editor such as WordPad.

STEP 3: Do a search on the following line:

sub display_credit_card_form

(This will get you to the start of the subroutine that displays the credit card entry form.)

STEP 4: About 17 lines down further in that subroutine, locate the following line:

$order_footer = &get_hidden_java_parameters();

STEP 5: Immediately BEFORE that line, add these three lines:

$totals_total = &strip_letters($totals_total);
$formatted_total = sprintf("%s %.2f",$currency_symbol,$totals_total);
$order_form_html =~ s/USHOP_TOTAL/$formatted_total/g;

STEP 6: Save the script... as TEXT if your editor asks... and try it out as per the instructions below.

The above modification will allow you to add the keyword "USHOP_TOTAL" anywhere on your creditcard_template.html file... and that "USHOP_TOTAL" keyword will be replaced at runtime by the current order total.... FORMATTED TO TWO DECIMAL PLACES.

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents
 
10 . ""RE: RE: Passing variables to CP pag""
Posted by Les on Sep-10-02 at 06:07 AM (EST)
Bill,

That's sorted it out :)

Thank you very much.

I really appreciate your help.

Thanks again

Regards

Les

Remove this Message: Administrator and Moderator onlyClick to Send Alert Message to the Administrator Click to edit this messageClick here to reply to this messageClick here to reply to this message with quotesClick to goto the Table of Contents


Archive This Thread: Admin and Moderator OnlyRemove This Thread: Admin and Moderator Only
Click here to goto Click here to goto the Lobby

 

 

 

 

 

 

 

 

 

 

 

 
Questions or problems regarding this bulletin board should be directed to Webmaster
©1997-1999 by DCScripts. All rights reserved.