Jump to content
xt:Commerce Community Forum

produkt_options_****.html anpassen


xigns

Recommended Posts

Hallo,

mein Name ist Enrico, habe mir schon viele Lösungen selbst erlesen können, komme aber nun ohne Hilfe nicht weiter.

Ich hoffe ihr könnt mir vielleicht einen entscheidenden Tip geben.

Ich habe zwei Module installiert, eines welches den Attributpreis sofort berechnet und eines wo der Kunde einen Freitext zum Produkt mit angeben kann.

Beide Module funktionieren für sich einwandfrei, für die Preisberechnung muß ich eine "product_options_dropdown_javascript.html" auswählen, dann geht aber der Freitext nicht, es wird nur das angelegte Attributfeld angezeigt.

Für den Freitext müßte ich eine "product_options_freitext.html" aktivieren.

Nur dann funktioniert das mit der Preisberechnung nichtmehr.

Da beide Module sonst keine gemeinsam genutzten Dateien haben ausser die produkt_options_***.html dachte ich mir das man die Befehle beider html Dateien zusammenbringen muß damit beides funktioniert.

Hab es schon mit WinMerge probiert, aber da tauchen dann Attributfelder doppelt auf u.s.w., kurz ich bekomm das nicht hin;).

Hier mal beide Codes:

product_options_dropdown_javascript.html


{if $options!=''}

<table width="100" border="0" cellspacing="0" cellpadding="0">
{foreach name=outer item=options_data from=$options}
<tr>
<td class="main"><b>{$options_data.NAME}:</b> </td>
<td>
{* ATTRIBUTES_PRICES_JAVASCRIPT by *******.de *}
{* <select name="id[{$options_data.ID}]"> *}
<select name="id[{$options_data.ID}]" onChange="updatePrice()">
{* ATTRIBUTES_PRICES_JAVASCRIPT by *********.de END *}
{foreach key=key_data item=item_data from=$options_data.DATA}
<option value="{$item_data.ID}">{$item_data.TEXT} {if $item_data.PRICE !='' }{$item_data.PREFIX} {$item_data.PRICE}{/if} </option>
{/foreach}
</select>
</td>
</tr>
{/foreach}
</table>

{* ATTRIBUTES_PRICES_JAVASCRIPT by ********.de *}
<script language="javascript1.5" type="text/javascript">

function updatePrice() {literal}
{
{/literal}
var price = new Array();
var add_to_price = 0;

{foreach name=outer item=options_data from=$options}
price[{$options_data.ID}] = new Array();
{foreach key=key_data item=item_data from=$options_data.DATA}
price[{$options_data.ID}][{$item_data.ID}] = Number({$item_data.PREFIX}{$item_data.PRICE_PLAIN});
{/foreach}
var sel_index = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].selectedIndex;
var item_id = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].options[sel_index].value;
if (!isNaN(item_id))
add_to_price += price[{$options_data.ID}][item_id];
{/foreach}
var calculated_price = Number(original_price)+Number(add_to_price);
document.getElementById("price").firstChild.nodeValue = currencyToXTC(calculated_price);

{literal}
}
{/literal}


function toDecimalPlaces(x, n)
{literal}
{
{/literal}
if (n < 1 || n > 14) return false;
var e = Math.pow(10, n);
var k = (Math.round(x * e) / e).toString();
if (k.indexOf('.') == -1) k += '.';
k += e.toString().substring(1);
return k.substring(0, k.indexOf('.') + n+1);
{literal}
}
{/literal}


function currencyToXTC(str)
{literal}
{
{/literal}
var decimal_point = '{$DECIMAL_POINT}';
var decimal_places = {$DECIMAL_PLACES};
var thousands_point = '{$THOUSANDS_POINT}';
str = toDecimalPlaces(str,decimal_places);
var predecimal_part = str.substring(0,str.length-decimal_places-1);
var deicmal_part = str.substr(str.length-decimal_places,decimal_places);
if(thousands_point != "" && predecimal_part.length > 3){literal}{{/literal}
var predecimal_temp = predecimal_part;
var predecimal_part = "";
for(j = 3; j < predecimal_temp.length ; j+=3){literal}{{/literal}
var extrakt = predecimal_temp.slice(predecimal_temp.length - j, predecimal_temp.length - j + 3);
predecimal_part = thousands_point + extrakt + predecimal_part + "";
{literal}}{/literal}
var str_first = predecimal_temp.substr(0, (predecimal_temp.length % 3 == 0)?3:(predecimal_temp.length % 3));
predecimal_part = str_first + predecimal_part;
{literal}}{/literal}
return predecimal_part + decimal_point + deicmal_part;
{literal}
}
{/literal}


function currencyToJavaScript(str)
{literal}
{
{/literal}
var decimal_places = {$DECIMAL_PLACES};
var thousands_point = '{$THOUSANDS_POINT}';
str = str.toString()
var predecimal_part = str.substring(0,str.length-decimal_places-1);
var deicmal_part = str.substr(str.length-decimal_places,decimal_places);
if(thousands_point != "" && predecimal_part.length > 3)
predecimal_part = predecimal_part.replace(eval('/\\'+thousands_point+'/g'),'');
return Number(predecimal_part + '.' + deicmal_part);
{literal}
}
{/literal}

updatePrice();
</script>

{* ATTRIBUTES_PRICES_JAVASCRIPT by*******.de END *}
{/if}[/HTML]

product_options_freitext.html:

[HTML]<!--
/**
* ********* Freitext
* Addon for xt:Commerce 3.04
* compatible to SP1 + SP2.1
*
* product_options_freitext.html - 2006-09-28
* XTC-Template for product-options with a textfield
* set this as the product options template in Admin->New Product
* Comments: product options value musst be named: Freitext
*
* Copyright by ************
* [url]www.*********.de[/url]
*
* @author ********* <info@********.de>
* @package xtc_addons_freitext
*/

-->
{if $options!=''}

<table>
{foreach name=outer item=options_data from=$options}
<tr>
{if $options_data.DATA.0.TEXT == 'Freitext'}
<input type="hidden" name="product_options_id_freitext" value="{$options_data.ID}"/>
<td class="main"><b>{$options_data.NAME}:</b> </td>
<td class="main"><input type="text" name="freitext"/> </td>
{/if}
{if $options_data.DATA.0.TEXT != 'Freitext'}
<td class="main"><b>{$options_data.NAME}:</b> </td>
<td>
<select name="id[{$options_data.ID}]">
{foreach key=key_data item=item_data from=$options_data.DATA}
<option value="{$item_data.ID}">{$item_data.TEXT} {if $item_data.PRICE !='' }{$item_data.PREFIX} {$item_data.PRICE}{/if} </option>
{/foreach}
</select>
</td>
{/if}
</tr>
{/foreach}
</table>
{/if}

[/HTML]

Da der Code vom Freitext gar nicht so umfangreich aussieht wäre nun meine Frage wir man diesen in den vom Preisupdate einbauen kann?

Vielen Dank schonmal für einen Tip.

MfG Rico

PS: Hab die Quellen mal unkenntlich gemacht, weil ich mir nicht sicher bin ob das hier erwünscht ist, weil es sich um kostenlose Module handelt.

Link to comment
Share on other sites

Versuch mal das. Ich hab das aber nicht getestet.

PS: Hab die Quellen mal unkenntlich gemacht, weil ich mir nicht sicher bin ob das hier erwünscht ist, weil es sich um kostenlose Module handelt.

Das ist unproblematisch.

mfg



<!--
/**
* ********* Freitext
* Addon for xt:Commerce 3.04
* compatible to SP1 + SP2.1
*
* product_options_freitext.html - 2006-09-28
* XTC-Template for product-options with a textfield
* set this as the product options template in Admin->New Product
* Comments: product options value musst be named: Freitext
*
* Copyright by ************
* [url]www.*********.de[/url]
*
* @author ********* <info@********.de>
* @package xtc_addons_freitext
*/

-->
{if $options!=''}

<table>
{foreach name=outer item=options_data from=$options}
<tr>
{if $options_data.DATA.0.TEXT == 'Freitext'}
<input type="hidden" name="product_options_id_freitext" value="{$options_data.ID}"/>
<td class="main"><b>{$options_data.NAME}:</b> </td>
<td class="main"><input type="text" name="freitext"/> </td>
{/if}
{if $options_data.DATA.0.TEXT != 'Freitext'}
<td class="main"><b>{$options_data.NAME}:</b> </td>
<td>
<select name="id[{$options_data.ID}]" onChange="updatePrice()">
{foreach key=key_data item=item_data from=$options_data.DATA}
<option value="{$item_data.ID}">{$item_data.TEXT} {if $item_data.PRICE !='' }{$item_data.PREFIX} {$item_data.PRICE}{/if} </option>
{/foreach}
</select>
</td>
{/if}
</tr>
{/foreach}
</table>


{* ATTRIBUTES_PRICES_JAVASCRIPT by ********.de *}
<script language="javascript1.5" type="text/javascript">

function updatePrice() {literal}
{
{/literal}
var price = new Array();
var add_to_price = 0;

{foreach name=outer item=options_data from=$options}
price[{$options_data.ID}] = new Array();
{foreach key=key_data item=item_data from=$options_data.DATA}
price[{$options_data.ID}][{$item_data.ID}] = Number({$item_data.PREFIX}{$item_data.PRICE_PLAIN});
{/foreach}
var sel_index = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].selectedIndex;
var item_id = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].options[sel_index].value;
if (!isNaN(item_id))
add_to_price += price[{$options_data.ID}][item_id];
{/foreach}
var calculated_price = Number(original_price)+Number(add_to_price);
document.getElementById("price").firstChild.nodeValue = currencyToXTC(calculated_price);

{literal}
}
{/literal}


function toDecimalPlaces(x, n)
{literal}
{
{/literal}
if (n < 1 || n > 14) return false;
var e = Math.pow(10, n);
var k = (Math.round(x * e) / e).toString();
if (k.indexOf('.') == -1) k += '.';
k += e.toString().substring(1);
return k.substring(0, k.indexOf('.') + n+1);
{literal}
}
{/literal}


function currencyToXTC(str)
{literal}
{
{/literal}
var decimal_point = '{$DECIMAL_POINT}';
var decimal_places = {$DECIMAL_PLACES};
var thousands_point = '{$THOUSANDS_POINT}';
str = toDecimalPlaces(str,decimal_places);
var predecimal_part = str.substring(0,str.length-decimal_places-1);
var deicmal_part = str.substr(str.length-decimal_places,decimal_places);
if(thousands_point != "" && predecimal_part.length > 3){literal}{{/literal}
var predecimal_temp = predecimal_part;
var predecimal_part = "";
for(j = 3; j < predecimal_temp.length ; j+=3){literal}{{/literal}
var extrakt = predecimal_temp.slice(predecimal_temp.length - j, predecimal_temp.length - j + 3);
predecimal_part = thousands_point + extrakt + predecimal_part + "";
{literal}}{/literal}
var str_first = predecimal_temp.substr(0, (predecimal_temp.length % 3 == 0)?3:(predecimal_temp.length % 3));
predecimal_part = str_first + predecimal_part;
{literal}}{/literal}
return predecimal_part + decimal_point + deicmal_part;
{literal}
}
{/literal}


function currencyToJavaScript(str)
{literal}
{
{/literal}
var decimal_places = {$DECIMAL_PLACES};
var thousands_point = '{$THOUSANDS_POINT}';
str = str.toString()
var predecimal_part = str.substring(0,str.length-decimal_places-1);
var deicmal_part = str.substr(str.length-decimal_places,decimal_places);
if(thousands_point != "" && predecimal_part.length > 3)
predecimal_part = predecimal_part.replace(eval('/\\'+thousands_point+'/g'),'');
return Number(predecimal_part + '.' + deicmal_part);
{literal}
}
{/literal}

updatePrice();
</script>

{* ATTRIBUTES_PRICES_JAVASCRIPT by*******.de END *}
{/if}


{* ATTRIBUTES_PRICES_JAVASCRIPT by ********.de *}
<script language="javascript1.5" type="text/javascript">

function updatePrice() {literal}
{
{/literal}
var price = new Array();
var add_to_price = 0;

{foreach name=outer item=options_data from=$options}
price[{$options_data.ID}] = new Array();
{foreach key=key_data item=item_data from=$options_data.DATA}
price[{$options_data.ID}][{$item_data.ID}] = Number({$item_data.PREFIX}{$item_data.PRICE_PLAIN});
{/foreach}
var sel_index = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].selectedIndex;
var item_id = document.getElementById("cart_quantity").elements["id[{$options_data.ID}]"].options[sel_index].value;
if (!isNaN(item_id))
add_to_price += price[{$options_data.ID}][item_id];
{/foreach}
var calculated_price = Number(original_price)+Number(add_to_price);
document.getElementById("price").firstChild.nodeValue = currencyToXTC(calculated_price);

{literal}
}
{/literal}


function toDecimalPlaces(x, n)
{literal}
{
{/literal}
if (n < 1 || n > 14) return false;
var e = Math.pow(10, n);
var k = (Math.round(x * e) / e).toString();
if (k.indexOf('.') == -1) k += '.';
k += e.toString().substring(1);
return k.substring(0, k.indexOf('.') + n+1);
{literal}
}
{/literal}


function currencyToXTC(str)
{literal}
{
{/literal}
var decimal_point = '{$DECIMAL_POINT}';
var decimal_places = {$DECIMAL_PLACES};
var thousands_point = '{$THOUSANDS_POINT}';
str = toDecimalPlaces(str,decimal_places);
var predecimal_part = str.substring(0,str.length-decimal_places-1);
var deicmal_part = str.substr(str.length-decimal_places,decimal_places);
if(thousands_point != "" && predecimal_part.length > 3){literal}{{/literal}
var predecimal_temp = predecimal_part;
var predecimal_part = "";
for(j = 3; j < predecimal_temp.length ; j+=3){literal}{{/literal}
var extrakt = predecimal_temp.slice(predecimal_temp.length - j, predecimal_temp.length - j + 3);
predecimal_part = thousands_point + extrakt + predecimal_part + "";
{literal}}{/literal}
var str_first = predecimal_temp.substr(0, (predecimal_temp.length % 3 == 0)?3:(predecimal_temp.length % 3));
predecimal_part = str_first + predecimal_part;
{literal}}{/literal}
return predecimal_part + decimal_point + deicmal_part;
{literal}
}
{/literal}


function currencyToJavaScript(str)
{literal}
{
{/literal}
var decimal_places = {$DECIMAL_PLACES};
var thousands_point = '{$THOUSANDS_POINT}';
str = str.toString()
var predecimal_part = str.substring(0,str.length-decimal_places-1);
var deicmal_part = str.substr(str.length-decimal_places,decimal_places);
if(thousands_point != "" && predecimal_part.length > 3)
predecimal_part = predecimal_part.replace(eval('/\\'+thousands_point+'/g'),'');
return Number(predecimal_part + '.' + deicmal_part);
{literal}
}
{/literal}

updatePrice();
</script>

{* ATTRIBUTES_PRICES_JAVASCRIPT by*******.de END *}
{/if}

[/php]

Link to comment
Share on other sites

Danke für die schnelle Antwort.

Kann es leider nicht testen, mir ist der Shop grad abgeschmiert. Keine Ahnung warum, komme nur noch auf die verhauene Startseite, keine Bilder mehr, keine Links funktionieren.

Nunja, mal sehen wo der Fehler liegt.

Per FTP sind alle Dateien da, hab ja auch nur die produkt_options mit nem neuen Namen hochgeladen.

Weißt Du da vielleicht auch noch einen Rat?

MfG Rico

Link to comment
Share on other sites

Habe es heute nochmal mit Deinem Script probiert, die Preisberechnung haut da nicht hin.

Stimmt der Code? Da er im unteren Teil doppelt ist. Ausserdem wird das zum Code gehörende letzte if nicht als Code erkannt, hat das was zu sagen?

MfG Rico

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...