uShop English (U.S.) for 179!

uStorekeeper English (U.S.) for 149!

 Products
       uTest
       uReserve
       uShop
       uStorekeeper
       uGolf
       uDirectory
       uSignIn
 Tech Support
       Support Policy
       Knowledge Base
            uTest
            uReserve
            uShop
            uStorekeeper
            uGolf
            uDirectory
            uSignIn
       Documentation
       Reference Sites
 Legal
       Software Piracy
       Legal Notices
       Privacy Policy
       Licensing
 Miscellaneous
       Reseller Info
       Contact Us
       Site Map
Passing variables to CP pages

Knowledge Base Lobby : uShop Support Conference : General Questions
Oct-22-17 04:11 AM EST
Original Message
Passing variables to CP pages
Author garylane on 08-22-2002 at 13:05 (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?
TABLE OF CONTENTS

Table Of Contents
  RE: Passing variables to CP pages Bill Weiner, 2002-08-23 04:41:16 (1)
            RE: Passing variables to CP pag garylane, 2002-08-23 08:29:55 (2)
                 RE: RE: Passing variables to CP pag Bill Weiner, 2002-08-26 04:38:12 (3)
                      "RE: RE: Passing variables to CP pag" Les, 2002-08-29 07:54:43 (4)
                           RE: RE: Passing variables to CP pag Bill Weiner, 2002-08-30 04:56:10 (5)
                                "RE: RE: Passing variables to CP pag" Les, 2002-09-06 09:29:51 (6)
                                     RE: RE: Passing variables to CP pag Bill Weiner, 2002-09-09 06:51:20 (7)
                                          "RE: RE: Passing variables to CP pag" Les, 2002-09-09 08:31:40 (8)
                                               RE: RE: Passing variables to CP pag Bill Weiner, 2002-09-10 05:05:56 (9)
                                                    "RE: RE: Passing variables to CP pag" Les, 2002-09-10 06:07:31 (10)

Messages In This Discussion
         1. RE: Passing variables to CP pages
        Author Bill Weiner on 08-23-2002 at 04:41 (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.
TABLE OF CONTENTS
                 2. RE: Passing variables to CP pag
                Author garylane on 08-23-2002 at 08:29 (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.
TABLE OF CONTENTS
                         3. RE: RE: Passing variables to CP pag
                        Author Bill Weiner on 08-26-2002 at 04:38 (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.
TABLE OF CONTENTS
                                 4. "RE: RE: Passing variables to CP pag"
                                Author Les on 08-29-2002 at 07:54 (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.
TABLE OF CONTENTS
                                         5. RE: RE: Passing variables to CP pag
                                        Author Bill Weiner on 08-30-2002 at 04:56 (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.)
TABLE OF CONTENTS
                                                 6. "RE: RE: Passing variables to CP pag"
                                                Author Les on 09-06-2002 at 09:29 (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
TABLE OF CONTENTS
                                                         7. RE: RE: Passing variables to CP pag
                                                        Author Bill Weiner on 09-09-2002 at 06:51 (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.
TABLE OF CONTENTS
                                                                 8. "RE: RE: Passing variables to CP pag"
                                                                Author Les on 09-09-2002 at 08:31 (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
TABLE OF CONTENTS
                                                                         9. RE: RE: Passing variables to CP pag
                                                                        Author Bill Weiner on 09-10-2002 at 05:05 (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.
TABLE OF CONTENTS
                                                                                 10. "RE: RE: Passing variables to CP pag"
                                                                                Author Les on 09-10-2002 at 06:07 (EST)
Bill,

That's sorted it out :)

Thank you very much.

I really appreciate your help.

Thanks again

Regards

Les
TABLE OF CONTENTS

© 2003 Microburst Technologies, Inc.