add estimated shipping functionnality in cart

This commit is contained in:
Julien Chanséaume
2014-04-25 09:43:22 +02:00
parent f556a7d149
commit ac51ab21e4
7 changed files with 341 additions and 6 deletions

View File

@@ -115,17 +115,57 @@
<span class="price">{$real_price * $QUANTITY} {currency attr="symbol"}</span>
</td>
</tr>
{/loop}
{postage}
{assign var="postageAmount" value=$postage }
<tr>
<td class="product" colspan="2">
<form action="{url path="/cart/country"}" class="form-inline" method="post">
<h3>
{intl l="Estimated shipping "}
{if $is_customizable == false}
{loop type="country" name="countryLoop" id="$country_id"}
{intl l="for"} {$TITLE}
{/loop}
{/if}
</h3>
{if $is_customizable}
<div>
<label for="cart-country">{intl l="Select your country:"}</label>
<select id="cart-country" name="country">
{loop type="country" name="countryLoop" with_area="true"}
<option value="{$ID}" {if $ID == $country_id }selected="selected" {/if}>{$TITLE}</option>
{/loop}
</select>
<a class="btn btn-change-country" href="#"><i class="icon-refresh"></i> {intl l="update"}</a>
</div>
{/if}
{if $delivery_id != 0 }
<div>
{intl l="with:"} {loop type="delivery" name="deliveryLoop" id=$delivery_id}{$TITLE} {/loop}
</div>
{else}
<div class="alert alert-danger">
{intl l="No deliveries available for this cart and this country"}
</div>
{/if}
</form>
</td>
<td class="unitprice">{$postage} {currency attr="symbol"}</td>
<td class="qty">-</td>
<td class="subprice">{$postage} {currency attr="symbol"}</td>
</tr>
{/postage}
</tbody>
<tfoot>
<tr >
<tr>
<td colspan="3" class="empty">&nbsp;</td>
<th class="total">{intl l="Total"}</th>
<td class="total">
<div class="total-price">
<span class="price">{cart attr="total_taxed_price_without_discount"} {currency attr="symbol"}</span>
</div>
{assign var="totalAmount" value={cart attr='total_taxed_price_without_discount'} + $postageAmount }
<span class="price">{$totalAmount} {currency attr="symbol"}</span>
</div>cart
</td>
</tr>
</tfoot>
@@ -169,6 +209,11 @@
$("select[name=quantity]").change(function(){
$(this).parents('form').submit();
});
$(".btn-change-country").click(function(e){
e.preventDefault();
var $form = $(this).parents('form');
$form.submit();
})
});
</script>
{/block}