Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 03-01-2006 20:02:49

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

New Dynamic Price Change Hack

Hi Gang,

I got really intrigued about the idea of having the displayed product price change dynamically with product option selection and I decided I'd like to implement this feature.  There was a previous solution to this on the board, but it didn't work for all form field types (only select boxes), and I wanted a more complete solution.  I ended up pretty much starting over from scratch, which is why I'm starting a new thread.  But nonetheless, many thanks and kudos to Mike (mikeyt) for getting this project started and giving me the inspiration.  Also, big thanks to Big Dave and Charlie (celdirect) for beta testing this mod for me!



On your product detail pages, when a customer modifies an option, the price that is displayed will update automatically to show the total price, including option prices.  Without this mod, the customer will not know the total price until they add the product to the cart.  This can lead to a lot of unnecessary cart adds and could cause lost sales if the customer is surprised when they see the total price.  This mod will work with all form field types used in ccp51 product options.  It will also work with regular pricing and sale pricing, with or without recurring pricing active.


* There is only one significant limitation - your option ID's cannot be plain numerals (1,2,3,etc).  It doesn't matter what your option names or descriptions are, but the ID's have to be something other than a plain number.  Most other option ID's will work, including most symbols.  But if an option ID is not acceptable, then that option will not update the price.  All other options on the page with valid ID's will continue to udpate though.  So if you get one single option that doesn't update, you'll need to change its ID.
* This mod will not cause any price change for text boxes or text areas in the options area.  This is not really practical without a lot of site specific code. 
* This mod requires javascript to work.  If the customer has javascript disabled (2-3% of users, I'm given to understand), the price will not update.  However, the script degrades cleanly to a static price display if javascript is disabled, so there is no loss for those customers.
* As written, this mod will not work with recurring based pricing, volume based pricing, or option based pricing (there's no display to update).  It could easily enough be made to work with those pricing methods if you wanted to change the price display element to include the price.



I've done my best to add plenty of error checking and cross browser compatibility.  My beta testers and I have tested on IE, FF, and Opera.  I tried to think of every possible weird thing that could happen and other than the limitation on option id's, I haven't been able to break the script yet - nor have my beta testers. However, if you encounter a situation that does break it, let me know and I'll see what I can do.



This is going to be a pretty long post, so I apologize in advance.  If you're working on a live site, I recommend performing the steps in the order given here, to keep things working.  Also, this is a big mod, so a backup is strongly recommended.  Charlie (celdirect) has pointed out that because of VAT pricing, there are some minor differences in the implementation on the UK/EU version of CCP51.  He will follow up this post with his corrections/changes for the UK/EU version.  Thanks Charlie!



In the directory ccp51/media/javascript/, add a new file called priceupdate.js.  The contents of this file should be:

Code:

// Dynamic Price Changer for CCP51
// Rachael Katz 03-01-2006

function updatePrice() {
var f="NO_OPTIONS";
// Find if we have a form with options
for (var i=0; i < document.forms.length; i++) {
  if (document.forms[i].optionfields) {
    f = i;
  } // End of if
} //end of for
// Only run sript if we have options
if (f != "NO_OPTIONS") {
  optionfieldsarray = eval('document.forms[' + f + '].optionfields.value.split("|")');
  baseregprice=document.forms[f].origregprice.value;
  var pricechange=0;
  for (var i=0; i < (optionfieldsarray.length); i=i+2) {
    if (optionfieldsarray[i+1] == 'SELECT' || optionfieldsarray[i+1] == 'SELECT-MULT') {
      fieldname = optionfieldsarray[i] + "\"][\"options";
      qualifier = "selected";
    } else {
      fieldname = optionfieldsarray[i];
      qualifier = "checked";
    } // End of if 
    if (eval('document.forms[' + f + '][\"' + fieldname + '\"][0]')) {    
      for (j=0;j<eval('document.forms[' + f + '][\"' + fieldname + '\"].length');j++) {
        if (eval('document.forms[' + f + '][\"' + fieldname + '\"][' + j + '].' + qualifier)) {
          optarray = eval('document.forms[' + f + '][\"' + fieldname + '\"][' + j + '].value.split("|")');
          if (optarray[2] == 'D') {          
            pricechange = pricechange - parseFloat(optarray[3]);
          } else if (optarray[2] == 'I') {
            pricechange = pricechange + parseFloat(optarray[3]);
          } // End of if
        } // End of if 
      } // End of for
    } else { 
      if (eval('document.forms[' + f + '][\"' + fieldname + '\"].' + qualifier)) {
        optarray = eval('document.forms[' + f + '][\"' + fieldname + '\"].value.split("|")');
        if (optarray[2] == 'D') {          
          pricechange = pricechange - parseFloat(optarray[3]);
        } else if (optarray[2] == 'I') {
          pricechange = pricechange + parseFloat(optarray[3]);
        } // End of if
      } // End of if 
    } // End of if
  } // End of for loop
  regprice = parseFloat(baseregprice) + pricechange;
  // Handle sub-zero prices
  if (regprice < 0) { 
    regprice = 0; 
  } // End of if
  // Fix decimal places
  regprice = regprice.toFixed(2);
  // Update Regular Price
  if (document.getElementById) {
    document.getElementById("price_reg").innerHTML = regprice;
  } else if (document.all) {
    document.forms[f].price_reg.innerHTML = regprice;
  } // End of if
  // Update Sale Price if it Exists
  if (document.forms[f].origsaleprice) {
    basesaleprice=document.forms[f].origsaleprice.value;
    saleprice = parseFloat(basesaleprice) + pricechange;
    // Handle sub-zero prices
    if (saleprice < 0) { 
      saleprice = 0; 
    } // End of if
    // Fix decimal places
    saleprice = saleprice.toFixed(2);
    // Update Span Tag
    if (document.getElementById) {
      document.getElementById("price_sale").innerHTML = saleprice;
    } else if (document.all) {
      document.forms[f].price_sale.innerHTML = saleprice;
    } // End of if
  } // End of if
} // End of if
} // End of script

Permission to use this script is granted freely, provided the credits remain at the top.



Essentially, what we're doing in this step is adding some span tags around the price so we can update them.  I'm going to show what that looks like on my price elements.  If your price elements look different than mine, just put the <span ID...> and </span> tags like you see them here around the price you want to change.

Go to your admin area, HTML Pages and Elements ->Manage Site Elements and change the element content on each of the following elements:

- Category Product Sale Price Display -

Code:

<BR>Regularly: (CGIVAR)currency_symbol(/CGIVAR)<span ID="price_reg">(CGIVAR)product_regprice(/CGIVAR)</SPAN><BR>
On Sale: (CGIVAR)currency_symbol(/CGIVAR)<span ID="price_sale">(CGIVAR)product_saleprice(/CGIVAR)</SPAN>

- Category Product Regular Price Display -

Code:

<BR>Price: (CGIVAR)currency_symbol(/CGIVAR)<span ID="price_reg">(CGIVAR)product_regprice(/CGIVAR)</span>

- Category Product Sale Price (With Recurring) Display -

Code:

<BR>Regularly: (CGIVAR)currency_symbol(/CGIVAR)<span ID="price_reg">(CGIVAR)product_regprice(/CGIVAR)</SPAN><BR>
On Sale: (CGIVAR)currency_symbol(/CGIVAR)<span ID="price_sale">(CGIVAR)product_saleprice(/CGIVAR)</SPAN><BR>
Additional Monthly Charge: (CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_recurprice(/CGIVAR)

- Category Product Regular Price (With Recurring) Display -

Code:

<BR>Price: (CGIVAR)currency_symbol(/CGIVAR)<span ID="price_reg">(CGIVAR)product_regprice(/CGIVAR)</SPAN><BR>
Additional Monthly Charge: (CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_recurprice(/CGIVAR)



I've chosen to include the script in the product detail layouts.  This way, the script is not loaded on non-product pages, which saves some resources - even though the script is only 2k, why load it if you don't need it.  Also, you have the option of not putting the script on certain product display types so that if you use one display for products with options and another display for products without, you can keep the script from being loaded when unnecessary.  You don't have to do that, as the script will accomodate products with no options automatically, but it gives you some choices.  Go to your admin area, HTML Pages and Elements ->Manage Manage Product Detail Displays and make the following changes for each of the displays that you want to have updating prices:

In the Display Content textarea, at the very beginning, add the following:

Code:

<script type="text/javascript" src="(CGIVAR)url_media_path(/CGIVAR)/javascript/priceupdate.js"></script>

and in the same textarea, on the line before </FORM>, add:

Code:

<script type="text/javascript">
updatePrice();
</SCRIPT>

Do this for each type of product display that you use or that you want to have update the prices.



In this step, we are going to be making several changes to ste_prod.pl, which is located in ccp51/cgi-bin/library/modules.  I will go through the file in order, detailing each change.

In the subroutine ste_prod_show_price, make the following changes:

Change:

Code:

&display_print('ste_catprod_salprcr');

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_salprcr');

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="origsaleprice" VALUE="$product_saleprice">
ENDOFTEXT

Change:

Code:

&display_print('ste_catprod_salprc');

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_salprc');
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="origsaleprice" VALUE="$product_saleprice">
ENDOFTEXT

Change:

Code:

&display_print('ste_catprod_regprcr');

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_regprcr');

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
ENDOFTEXT

And finally, Change:

Code:

&display_print('ste_catprod_regprc');

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_regprc');

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
ENDOFTEXT

Next, in the subroutine ste_prod_show_options, make the following change:

Change:

Code:

#########
######### We match the returned related option references to
######### actual options, and if we have more than zero, we
######### continue.
#########

if ($optionproddisp_count ne "0") {

$count = "$optionproddisp_count";

#########
######### Print the table header.
#########

To:

Code:

#########
######### We match the returned related option references to
######### actual options, and if we have more than zero, we
######### continue.
#########

if ($optionproddisp_count ne "0") {

$count = "$optionproddisp_count";

#########
######### Create Hidden Input for Price Calculation
#########

foreach $row(@optionproddisp) {

($optionprod_id,$optionprod_name,$optionprod_descript,$optionprod_display_type,$optionprod_inv,$optionprod_required) = @$row;

if ($optionprod_id ne "" && $optionprod_display_type ne "TEXTBOX" && $optionprod_display_type ne "TEXTAREA"){

$optionfields = "$optionfields$optionprod_id\|$optionprod_display_type\|";

} ######### End of if statement statement.

} ######### End of for each

chop($optionfields);

print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="optionfields" VALUE="$optionfields">
ENDOFTEXT

#########
######### Print the table header.
#########

And finally, in the subroutine ste_prod_show_options_disp, make the following changes:

Change:

Code:

if ($display_count eq "1") {

print <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="$id" VALUE= "$optionsel_id|$optionsel_selname|$optionsel_pricech|$optionsel_price|$optionsel_weightch|$optionsel_weight|$optionsel_inv|$optionsel_recurprice" CHECKED> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color">$optionsel_selname$display_pricech</FONT><BR>
ENDOFTEXT

} else {

print <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="$id" VALUE= "$optionsel_id|$optionsel_selname|$optionsel_pricech|$optionsel_price|$optionsel_weightch|$optionsel_weight|$optionsel_inv|$optionsel_recurprice"> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color">$optionsel_selname$display_pricech</FONT><BR>
ENDOFTEXT

} ######### End of if statement.

To:

Code:

if ($display_count eq "1") {

print <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="$id" onclick="updatePrice()" VALUE= "$optionsel_id|$optionsel_selname|$optionsel_pricech|$optionsel_price|$optionsel_weightch|$optionsel_weight|$optionsel_inv|$optionsel_recurprice" CHECKED> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color">$optionsel_selname$display_pricech</FONT><BR>
ENDOFTEXT

} else {

print <<ENDOFTEXT;
<INPUT TYPE="RADIO" NAME="$id" onclick="updatePrice()" VALUE= "$optionsel_id|$optionsel_selname|$optionsel_pricech|$optionsel_price|$optionsel_weightch|$optionsel_weight|$optionsel_inv|$optionsel_recurprice"> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color">$optionsel_selname$display_pricech</FONT><BR>
ENDOFTEXT

} ######### End of if statement.

Change:

Code:

#########
######### Process type equals SELECT.
#########

} elsif ($display_type eq "SELECT") {

print <<ENDOFTEXT;
<SELECT NAME="$id">
ENDOFTEXT

To:

Code:

#########
######### Process type equals SELECT.
#########

} elsif ($display_type eq "SELECT") {

print <<ENDOFTEXT;
<SELECT NAME="$id" onchange="updatePrice()">
ENDOFTEXT

Change:

Code:

#########
######### Process type equals SELECT-MULT.
#########

} elsif ($display_type eq "SELECT-MULT") {

print <<ENDOFTEXT;
<SELECT NAME="$id" SIZE="5" MULTIPLE>
ENDOFTEXT

To:

Code:

#########
######### Process type equals SELECT-MULT.
#########

} elsif ($display_type eq "SELECT-MULT") {

print <<ENDOFTEXT;
<SELECT NAME="$id" SIZE="5" onchange="updatePrice()" MULTIPLE>
ENDOFTEXT

And last, but not least, change:

Code:

print <<ENDOFTEXT;
<INPUT TYPE="CHECKBOX" NAME="$id" VALUE= "$optionsel_id|$optionsel_selname|$optionsel_pricech|$optionsel_price|$optionsel_weightch|$optionsel_weight|$optionsel_inv|$optionsel_recurprice"> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color">$optionsel_selname$display_pricech</FONT><BR>
ENDOFTEXT

To:

Code:

print <<ENDOFTEXT;
<INPUT TYPE="CHECKBOX" NAME="$id" onclick="updatePrice()" VALUE= "$optionsel_id|$optionsel_selname|$optionsel_pricech|$optionsel_price|$optionsel_weightch|$optionsel_weight|$optionsel_inv|$optionsel_recurprice"> <FONT FACE="$html_base_font_face" SIZE="$html_base_font_size" COLOR="$html_base_font_color">$optionsel_selname$display_pricech</FONT><BR>
ENDOFTEXT



That should complete your installation.  Another fine hack from Rachael's Happy Hoppin' House of Hackery...

Enjoy!
Rachael :-)

EDIT:  Changed javascript to be more tolerant of option ID's.

Last edited by rachaelseven (09-16-2006 10:21:14)


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#2 03-01-2006 21:23:53

Big Dave
Member
Registered: 10-24-2003
Posts: 742

Re: New Dynamic Price Change Hack

I hope you all understand this... RACHAEL ROCKS !!

Offline

 

#3 03-01-2006 21:28:56

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

 


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#4 03-01-2006 21:32:22

celdirect
Member
From: UK
Registered: 04-01-2005
Posts: 782

Re: New Dynamic Price Change Hack

Hi,

For the Uk version of ccp5.1 you will need to do the following:

Read fully the post above made by (rachaelseven).

1) Conplete step one as above: Step One - Add a New Javascript

2) Complete step two as above:  Step 2 - Update Price Display Elements

If you use the VAT display options also change the following:

found in data/elements/

just put the <span ID...> and </span> tags like you see them in step two above, around the price you want to change in the folowing files:

Inc VAT:

ste_catprod_regprcr_ivat.txt
ste_catprod_regprc_ivat.txt
ste_catprod_salprcr_ivat.txt
ste_catprod_salprc_ivat.txt


exc VAT:

ste_catprod_regprcr_vat.txt
ste_catprod_regprc_vat.txt
ste_catprod_salprcr_vat.txt
ste_catprod_salprc_vat.txt

3) Complete step three as above: Step 3 - Modify Product Layouts

4) Step 4 - Modify the PERL : ONLY for UK version! follow below: (its the right curly brackets that need to be included in the UK version)

In this step, we are going to be making several changes to ste_prod.pl, which is located in ccp51/cgi-bin/library/modules. I will go through the file in order, detailing each change.

In the subroutine ste_prod_show, make the following changes:

Change:

Code:

&display_print('ste_catprod_salprcr');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_salprcr');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="origsaleprice" VALUE="$product_saleprice">
ENDOFTEXT

Change:


Code:

&display_print('ste_catprod_salprc');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_salprc');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="origsaleprice" VALUE="$product_saleprice">
ENDOFTEXT

Change:

Code:

&display_print('ste_catprod_regprcr');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_regprcr');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
ENDOFTEXT

And finally, Change:

Code:


&display_print('ste_catprod_regprc');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
ENDOFTEXT

To:

Code:

&display_print('ste_catprod_regprc');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
ENDOFTEXT

Next, in the subroutine ste_prod_show_options, make the following change:

As the post above (by Rachael) make the same changes.

-------End of Install-------

That should complete your installation. Another fine hack from Rachael's Happy Hoppin' House of Hackery...

Cheers
Charlie
;-)

P.S

I too think Rachael ROCkS!!!

A BIG thank-you goes out to Rachael for her help & input here on the forum smile  from me!

Offline

 

#5 03-02-2006 08:41:27

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack



Thanks for the UK updates, Charlie - that is awesome.  Also, I wanted to clarify the valid option ID's a little bit.  The option ID is called the Option Reference String on admin pages.  It's safe to try any ID you want.  In other words, it's perfectly safe to install the mod with whatever options you have definied.  If some of your option ID's are not valid, they just won't update the displayed price, that's all.  I improved the script to where it will accept almost any option ID, but it's gone as far as it can go - the remaining limitations are fundamental in the language.  Javascript and HTML just can't do certain things with fields that have numbers for names.  The individual option choices can be named anything you want, the option name and description can be anything at all - the only limitation is on the option ID.  And so far, the only ID's I can find that won't work are plain numbers. 

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#6 03-03-2006 07:29:46

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: New Dynamic Price Change Hack

Hey guys
Thanks to you both for your contributions to this mod...Really useful!  One problem with the UK customisation...I can't get my INCLUDING vat price to update.  I use excluding vat prices in click cart, and get it to work out the including vat price for me.
Any ideas?
Oli

Offline

 

#7 03-03-2006 07:40:46

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

Well, not having seen the UK version, I'm at a bit of a disadvantage.  The VAT pricing must be calculated in ste_prod.pl and I'm guessing that's where the issue must be.  Are there more lines similar to this for the VAT pricing?

Code:

&display_print('ste_catprod_salprcr_vat');
}
print <<ENDOFTEXT;
<INPUT TYPE="HIDDEN" NAME="price" VALUE="$product_saleprice">
<INPUT TYPE="HIDDEN" NAME="recurprice" VALUE="$product_recurprice">
ENDOFTEXT

If so, it might just be a matter of adding the lines:

Code:

<INPUT TYPE="HIDDEN" NAME="origregprice" VALUE="$product_regprice">
<INPUT TYPE="HIDDEN" NAME="origsaleprice" VALUE="$product_saleprice">

to those sections.

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#8 03-11-2006 04:04:25

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: New Dynamic Price Change Hack

Still no luck on this one, any pointers people?

Offline

 

#9 03-11-2006 09:27:58

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

Sorry, without the UK/EU version of ste_prod.pl to look at, I'm not going to be much help on this one.  The script does calculate two prices already.  So you should be able to modify the code a bit to calculate vat and non-vat pricing instead of regular and sale pricing.  You'll need to get some help from someone familiar with the EU/UK version though.  Sorry.

Rachael  sad


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#10 03-11-2006 10:50:35

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: New Dynamic Price Change Hack

Thanks Rach...Celdirect, are you in any position to offer some advice?

Offline

 

#11 06-07-2006 13:08:22

ellehazen
Member
Registered: 03-14-2006
Posts: 129

Re: New Dynamic Price Change Hack

This is amazing!!!! Although I am a bit confused in the implementation of step 2.  I'm not quite sure what exactly to insert and where to put the span tags since mine looks so different.  Everything else looks extremely straigtforward... I just dont want to mess my store up.

Anyhow, here is what my elements look like right now:

Category Product Sale Price Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
  <tr>
                        <td width="50%" height="20" class="prodprice">Sale:</td>
                        <td width="50%" align="right" height="20" class="saleprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_saleprice(/CGIVAR)</td>
                      </tr>
                     </table>

- Category Product Regular Price Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
 <tr>
                        <td width="50%" height="20" class="prodprice">Price:</td>
                        <td width="50%" align="right" height="20" class="regprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_regprice(/CGIVAR)</td>
                      </tr>
                      </table>

- Category Product Sale Price (With Recurring) Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
  <tr>
                        <td width="50%" height="20" class="prodprice">Sale:</td>
                        <td width="50%" align="right" height="20" class="saleprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_saleprice(/CGIVAR)</td>
                      </tr>
                     </table>
<table border="0" cellpadding="0" cellspacing="0" width="160">
  <tr>
                        <td width="50%" height="20" class="prodprice">Monthly:</td>
                        <td width="50%" align="right" height="20" class="regprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_recurprice(/CGIVAR)</td>
                      </tr>
                     </table>

- Category Product Regular Price (With Recurring) Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
  <tr>
                        <td width="50%" height="20" class="prodprice">Sale:</td>
                        <td width="50%" align="right" height="20" class="saleprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_regprice(/CGIVAR)</td>
                      </tr>
                     </table>
<table border="0" cellpadding="0" cellspacing="0" width="160">
  <tr>
                        <td width="50%" height="20" class="prodprice">Monthly:</td>
                        <td width="50%" align="right" height="20" class="regprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_recurprice(/CGIVAR)</td>
                      </tr>
                     </table>

-----------------------------------------------------------------------------------------------------------

I would LOVE to get this amazing hack you made working... Any help you can give is much appreciated!  Oh, and you certainly do ROCK, Rachael!!! wink

Thanks,

Michelle

Offline

 

#12 06-07-2006 19:25:35

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

Hi Michelle,

Thank you very much!  Looks like you have a skin on your cart - your elements certainly are different.  Let's give this a shot.  I believe your elements should look like:

Category Product Sale Price Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
 <tr>
                       <td width="50%" height="20" class="prodprice">Sale:</td>
                       <td width="50%" align="right" height="20" class="saleprice">(CGIVAR)currency_symbol(/CGIVAR)<span ID="price_sale">(CGIVAR)product_saleprice(/CGIVAR)</span></td>
                     </tr>
                    </table>

- Category Product Regular Price Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
<tr>
                       <td width="50%" height="20" class="prodprice">Price:</td>
                       <td width="50%" align="right" height="20" class="regprice">(CGIVAR)currency_symbol(/CGIVAR)<span ID="price_reg">(CGIVAR)product_regprice(/CGIVAR)</span></td>
                     </tr>
                     </table>

- Category Product Sale Price (With Recurring) Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
 <tr>
                       <td width="50%" height="20" class="prodprice">Sale:</td>
                       <td width="50%" align="right" height="20" class="saleprice">(CGIVAR)currency_symbol(/CGIVAR)<span ID="price_sale">(CGIVAR)product_saleprice(/CGIVAR)</span></td>
                     </tr>
                    </table>
<table border="0" cellpadding="0" cellspacing="0" width="160">
 <tr>
                       <td width="50%" height="20" class="prodprice">Monthly:</td>
                       <td width="50%" align="right" height="20" class="regprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_recurprice(/CGIVAR)</td>
                     </tr>
                    </table>

- Category Product Regular Price (With Recurring) Display -

Code:

<table border="0" cellpadding="0" cellspacing="0" width="160">
 <tr>
                       <td width="50%" height="20" class="prodprice">Sale:</td>
                       <td width="50%" align="right" height="20" class="saleprice">(CGIVAR)currency_symbol(/CGIVAR)<span ID="price_reg">(CGIVAR)product_regprice(/CGIVAR)</span></td>
                     </tr>
                    </table>
<table border="0" cellpadding="0" cellspacing="0" width="160">
 <tr>
                       <td width="50%" height="20" class="prodprice">Monthly:</td>
                       <td width="50%" align="right" height="20" class="regprice">(CGIVAR)currency_symbol(/CGIVAR)(CGIVAR)product_recurprice(/CGIVAR)</td>
                     </tr>
                    </table>

Give that a try and let me know how it works out for you.  Keep a copy of your elements as they are now, just in case we have it wrong.  I believe that should be your step 2 and the rest should be per the original post; but if you have any problems, let me know and I'll see if I can help.  Happy coding!

Rachael

Last edited by rachaelseven (09-29-2006 08:38:25)


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#13 06-07-2006 20:42:07

ellehazen
Member
Registered: 03-14-2006
Posts: 129

Re: New Dynamic Price Change Hack

It worked!!! Thanks a million, Rachael!

This ROCKS smile

Offline

 

#14 07-05-2006 17:59:46

ellehazen
Member
Registered: 03-14-2006
Posts: 129

Re: New Dynamic Price Change Hack

Hey Rachael smile Hope you are doing well.

Normally, I operate using Safari, and have had no problems getting the script to work. However, I just downloaded FireFox and I'm having a problem getting this to work in FireFox.  I noticed your original post says that it works in FF and I was wondering if you know why this is happening???

Thanks for your help!!!

Michelle
wwwroversallover.com/store

Offline

 

#15 07-05-2006 21:11:56

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

Hi Michelle,

I'm not sure entirely what the problem is here.  I know it works ok in FF as it is installed on my site.  When I tried your site in FF, the javascript console reported the following error:

Error: illegal character
Source File:
Line: 1

I looked at your script and it didn't look any different from mine, except for one thing - there is a space between every character in your script.  I have no idea why it would have pasted that way... did you do it on a Mac?  That's the only thing I can see that could be causing the error; but like I said, I'm really not sure why it is occurring.  Sorry.

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#16 07-05-2006 22:06:09

ellehazen
Member
Registered: 03-14-2006
Posts: 129

Re: New Dynamic Price Change Hack

Thanks for taking a look, Rachael...  And yes, I did do it on a Mac.  So where did you see the spaces, and do you think I should go back and change it all?  Do you think it would make a difference???

Offline

 

#17 07-06-2006 07:45:57

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

I had a hunch it was a Mac issue.  I think what's possibly happened is that your Mac somehow formatted the file differently and FF is just picky enough to care where the other browsers weren't.  The spaces are between each and every character in the file.  In other words, insted of 'subroutine' it says 's u b r o u t i n e'.  I don't think there are actually spaces in there through - more likely it's the difference in how Macs treat characters.  Hopefully someone else who knows the Mac issues better will jump in here.  But what I suspect you need to do is cut and paste the javascript with a different editor.  Or else, shoot me an email and I'll email you back with the file attached so you don't have to edit it at all.

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#18 07-06-2006 12:15:24

ellehazen
Member
Registered: 03-14-2006
Posts: 129

Re: New Dynamic Price Change Hack

Ok. Sent you an email smile

Offline

 

#19 07-08-2006 23:47:09

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: New Dynamic Price Change Hack

It's been a while but when I pasted this mod on to my mac's I didn't get spaces inbetwen the character but I got a lot of  extra characters at the end of the lines which I had to remove before I got it to work.

I haven't seen any problems in FF or Safai but I have noticed that it dosen't work in IE.

John

Offline

 

#20 07-09-2006 00:55:31

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

Hi John,

It should work in IE without a problem.  Do you have a link to a page where it doesn't work so I can take a look?

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#21 07-09-2006 17:20:25

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: New Dynamic Price Change Hack

Hi Rachael,

The site is at wwwslpdoghousemusic.com and you can look at the first item on the splash page (RG321MHMOL). I have added some to your original code but it should update Retail Price, Our Price, and the Layaway payment amount.

I mostly use Mac computers and I do know that I haven't got it to work in IE on the mac's but I can't remember if it didn't work on my PC laptop. I will have to try it again and see if it works there, I do know that it works in Safari, FF and Opra. I have checked the settings for IE and all the Java settings are turned on (Mac).

I know that I haven't said it but it is a nice mod and thanks for posting it.

John

Offline

 

#22 07-09-2006 17:30:03

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

Hi John,

Worked fine for me in IE6 under WinXP Pro - maybe it's just the Mac version of IE that doesn't work?  Anyway, it looks great and I really like what you did with the layaway amount, too - nice adaptation!

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#23 10-25-2006 04:00:42

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: New Dynamic Price Change Hack

Hi guys
Been using this mod for a while now, really good stuff.
Quick question, I have recently listed some products that load up with default options that contain Increases/Deductions in price.  How do I set the javascript to run on page load rather than after an update because at the moment, the price showing on page load is the list price in the sql table, and not the calculated price of the list price +/- the options loaded by default.

Offline

 

#24 10-25-2006 05:55:32

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: New Dynamic Price Change Hack

Check your completion of step 3.  The second part of step 3 has you put a script call near the end of the product detail display.  That will cause the script to run once as the page is loading and should make everything come up right the first time.  If you have a demo page, post the URL and I'll take a look.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#25 10-25-2006 06:34:53

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: New Dynamic Price Change Hack

Offline

 

Board footer