HaaseIT/HCSF

View on GitHub
src/views/shop/shoppingcarttable.twig

Summary

Maintainability
Test Coverage
{% if customdata.shoppingcart.readonly == false %}
    <script language="JavaScript" async="async">
        function removeFromCart(id) {
            var o = new Option("0", "0");
/// jquerify the DOM object 'o' so we can use the html method
            $(o).html("0");
            $("#shc_amount_"+id).append(o);
            $("#shc_amount_"+id).val("0");
            $("#shc_form_"+id).submit();
        }
        function updateAmount(id) {
            $("#shc_form_"+id).submit();
        }
    </script>
    {% set formcounter = 0 %}
{% endif %}
<div id="cart-wrapper">
    <div id="cart-header">
        <div class="pure-u-1 pure-u-md-1-2">{{ T("shoppingcart_headline_item") }}</div><div
                class="pure-u-1 pure-u-md-1-6 text-center">{{ T("shoppingcart_headline_amount") }}</div><div
                class="pure-u-1 pure-u-md-1-6 text-center">{{ T("shoppingcart_headline_price_single") }}</div><div
                class="pure-u-1 pure-u-md-1-6 text-center">{{ T("shoppingcart_headline_price_amount") }}</div>
    </div>
    {% for thiscartkey, thiscart in customdata.shoppingcart.cart %}
        {% if customdata.shoppingcart.readonly == false %}
            <form action="/_misc/update-cart.html" method="POST" id="shc_form_{{ formcounter }}" class="pure-form pure-form-stacked">
            {% if custom_order_fields is defined and custom_order_fields|length > 0 %}
                {% set thiscartkeys = thiscartkey|split('|') %}
                <input type="hidden" name="itemno" value="{{thiscartkeys[0]}}">
                {% for thiscartkeys_current in thiscartkeys %}
                    {% set thiscartkeys_current_split = thiscartkeys_current|split(':') %}
                    {% if thiscartkeys_current_split[0] in custom_order_fields %}
                        <input type="hidden" name="{{ thiscartkeys_current_split[0] }}" value="{{ thiscartkeys_current_split[1] }}">
                    {% endif %}
                {% endfor %}
            {% else %}
                <input type="hidden" name="itemno" value="{{thiscartkey}}">
            {% endif %}
        {% endif %}
        <div class="cart-product">
            <div class="pure-u-1 pure-u-md-1-6">{{thiscart.name}}</div><div
                    class="pure-u-1 pure-u-md-1-6">
                <img src="{{ customdata.shoppingcart.readonly == false ? ImgURL('/_img/items/'~thiscart.img, 100) : '' }}{{ customdata.shoppingcart.readonly == true ? thiscart.img : '' }}">
            </div><div
                    class="pure-u-1 pure-u-md-1-6">
                {% if custom_order_fields is defined and custom_order_fields|length > 0 %}
                    {% set thiscartkeys = thiscartkey|split('|') %}
                    {{T("shoppingcart_item_itemno")}} {{thiscartkeys[0]}}
                    {% for thiscartkeys_current in thiscartkeys %}
                        {% set thiscartkeys_current_split = thiscartkeys_current|split(':') %}
                        {% if thiscartkeys_current_split[0] in custom_order_fields %}
                            <br>{{ T("shoppingcart_item_" ~ thiscartkeys_current_split[0] )}} {{ thiscartkeys_current_split[1] }}
                        {% endif %}
                    {% endfor %}
                {% else %}
                    {{T("shoppingcart_item_itemno")}} {{thiscartkey}}
                {% endif %}
            </div><div
                    class="pure-u-1 pure-u-md-1-6 text-center"><strong class="md-invisible">Anzahl</strong>
                {% if customdata.shoppingcart.readonly != false %}
                    {{thiscart.amount}}x
                {% else %}
                    {{ macro.select('amount', orderamounts, thiscart.amount, 'shc_amount_'~formcounter, 'pure-u-1', false, false, false, 'onChange="javascript:updateAmount(' ~ formcounter ~ ')"') }}
                    <p><a href="javascript:removeFromCart('{{ formcounter }}');" class="cart-product-remove">{{ T("shoppingcart_remove") }}</a></p>
                {% endif %}
            </div><div
                    class="pure-u-1 pure-u-md-1-6 text-center"><strong class="md-invisible">{{ T("shoppingcart_headline_price_single") }} </strong>{{thiscart.price.brutto_use|number_format(numberformat_decimals, numberformat_decimal_point, numberformat_thousands_seperator)}} {{currency}}
            </div><div
                    class="pure-u-1 pure-u-md-1-6 text-center"><strong class="md-invisible">{{ T("shoppingcart_headline_price_amount") }} </strong>{{(thiscart.price.brutto_use * thiscart.amount)|number_format(numberformat_decimals, numberformat_decimal_point, numberformat_thousands_seperator)}} {{currency}}</div>
        </div>
        {#
        {% if (customdata.shoppingcart.readonly == true and customdata.shoppingcart.customergroup != '') %}
            {% if thiscart.rg_rebate != '' %}
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{thiscart.rg}}
                {{ thiscart.rg_rebate != '' and thiscart.rg != '' ? '/' : '' }}
                {{thiscart.rg_rebate}}%
            {% endif %}
        {% elseif customdata.shoppingcart.readonly == true %}
            &nbsp;
        {% endif %}
        #}
        {% if customdata.shoppingcart.readonly == false %}
            </form>
            {% set formcounter = formcounter + 1 %}
        {% endif %}
    {% endfor %}

    <div id="cart-summary">
        {% if customdata.shoppingcart.additionalcoststoitems.fVersandkostenbrutto > 0 %}
            <div class="pure-u-1 pure-u-md-2-3"></div><div
                class="pure-u-1 pure-u-md-1-6 text-center"><strong>{{T("shoppingcart_tablefoot_shippingcost")}}</strong>
        </div><div
                class="pure-u-1 pure-u-md-1-6 text-center" id="shcshippingvalue">{{customdata.shoppingcart.additionalcoststoitems.fVersandkostenbrutto|number_format(numberformat_decimals, numberformat_decimal_point, numberformat_thousands_seperator)}} {{currency}}</div>
        {% endif %}
        <div class="pure-u-1 pure-u-md-2-3"></div><div
                class="pure-u-1 pure-u-md-1-6 text-center"><strong>{{T("shoppingcart_tablefoot_sumbrutto")}}</strong>
        </div><div
                class="pure-u-1 pure-u-md-1-6 text-center" id="shcbruttovalue">{{customdata.shoppingcart.additionalcoststoitems.fGesamtbrutto|number_format(numberformat_decimals, numberformat_decimal_point, numberformat_thousands_seperator)}} {{currency}}</div>
    </div>
</div>