Jump to content
xt:Commerce Community Forum

Noch xx Euro bis zum Gratisversand


Recommended Posts

Hallo,

ich möchte im Warenkorb eine Berechnung anzeigen, die angibt, wieviel Euro noch fehlen, bis die Schwelle zum Gratisversand erreicht ist.

Beispiel:

Ab 50 EUR ist der Versand kostenlos.

Ich lege einen Artikel für 20 EUR in den Warenkorb.

Dann möchte ich im Warenkorb angezeigt haben:

"Noch 30 EUR bis zum Gratisversand".

Anbei ein Beispiel von einem anderen Webshop.

Hat jemand so etwas schon realisiert? Gibt es dazu eine Vorlage, eine Idee wie man das machen könnte?

Danke für Eure Hilfe!!

post-98717-14337915252218_thumb.jpg

Link to comment
Share on other sites

  • 4 weeks later...

Vielen Dank! Ich habe es mittlerweile auch selber hinbekommen. Leider nicht so ganz elegant programmiert, da es hart kodiert ist und nicht vom Versandpreis automatisch berechnet wird.

Hier ist der Code falls jemand etwas ähnliches sucht:

box_cart.html

{assign var=cart value=$cart_total} 

{php} 

    // holen der Variablen aus dem Template, ist formatiert mit Komma und Eurozeichen ! 

    $cart_total = $this->get_template_vars('cart'); 

    // Als Zahl formatieren 

    // entferne vorderen String 

	$cart_total = str_replace('<span class="price"> ','',$cart_total); 

    // entferne hinteren String 

    $cart_total = str_replace(' EUR</span>','',$cart_total); 

	// entferne Tausender-Punkte 

    $cart_total = str_replace('.','',$cart_total); 

    // tausche Komma gegen Punkt 

    $cart_total = str_replace(',','.',$cart_total); 

    // Ausgabe ans Template 


	if ($cart_total > 50) {

		$Total = $cart_total ;

	} else {

		$Total = $cart_total +3.9;

		$Rest = 50 - $cart_total;

	}

	$Total = sprintf("%01.2f", $Total);

	$Total = str_replace('.', ',', $Total);

	$Rest = sprintf("%01.2f", $Rest);

    $Rest = str_replace('.', ',', $Rest);

    $this->assign ('carttotal',$cart_total); 

	$this->assign ('gesamtsumme',$Total); 

	$this->assign ('rest',$Rest); 

{/php}  

{if $smarty.const._CUST_STATUS_SHOW_PRICE eq '1'}

{if $show_cart_content == true}

		<h2 class="boxcartheader">{txt key=TEXT_CART}</h2>

		<div class="boxcartbody">

			{foreach name=aussen item=data from=$cart_data}

				<p>{$data.products_quantity} x <a href="{$data.products_link}">{$data.products_name}</a></p>

			{/foreach}

			<div class="hr"></div>

			<p style="text-align:right">

		    {foreach name=aussen item=tax_data from=$cart_tax}

		    {txt key=TEXT_TAX} {$tax_data.tax_key}%: {$tax_data.tax_value.formated}<br />

		    {/foreach}

			<strong>{txt key=TEXT_SUB_TOTAL}:{$cart_total}</strong>

			{if $carttotal > 50}

			<br />versandkostenfrei<br />

			{else}

			<br />Versandkosten: 3,90 EUR<br />

			{/if}

			<b>Gesamtsumme: <font size="4">{$gesamtsumme}  EUR</font></b><br />

			{if $carttotal < 50}

			<br />Noch <font color="#4059e8"><b>{$rest} EUR </b></font> bis zum <font color="#4059e8"><b>Gratisversand </b></font><br />

			{/if}

			{if $cart_total_weight > 0}<br />({txt key=TEXT_PRODUCTS_WEIGHT}: {$cart_total_weight|number_format:2:",":"."} KG){/if}

			<br />

			</p>

			<div class="hr"></div>

			<p style="text-align:right;"><a href="{link page='cart' conn=SSL}"><strong>{txt key=TEXT_CART} »</strong></a></p>

		</div>


{else}


		<h2 class="boxcartheader">{txt key=TEXT_CART}</h2>

			<div class="boxcartbody">

			<p>{txt key=TEXT_EMPTY_CART}<br /><br /><a href="{link page='cart' conn=SSL}">{txt key=TEXT_CART} »</a></p>

		</div>


{/if}

{/if}

Link to comment
Share on other sites

Archived

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

×
  • Create New...