Post by mkhurram92 » Sat Jun 12, 2021 2:35 pm

I am working on OpenCart 3.0. I need to add cart in footer. This code works perfectly in old opencart version(TPL) but not working in (TWIG). Code is as below.
<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->
//Code in Stylesheet
#bottom_cart_section {
position:fixed;
bottom:0px;
height:100px;
width:100%;
background-color:#FFF;
box-shadow:0px 0px 12px 1px #CCC;
padding: 10px 5%;
z-index:95;
}
<!-- end snippet -->

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->


//Code on footer form
<div id="bottom_cart_section">
{{ cart }}
</div>

<!-- end snippet -->

Cart code is as below

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

<div id="cart" class="btn-group btn-block">
<button type="button" data-toggle="dropdown" data-loading-text="{{ text_loading }}" class="btn btn-inverse btn-block btn-lg dropdown-toggle"><i class="fa fa-shopping-cart"></i> <span id="cart-total">{{ text_items }}</span></button>
<ul class="dropdown-menu pull-right">
{% if products or vouchers %}
<li>
<table class="table table-striped">
{% for product in products %}
<tr>
<td class="text-center">{% if product.thumb %} <a href="{{ product.href }}"><img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-thumbnail" /></a> {% endif %}</td>
<td class="text-left"><a href="{{ product.href }}">{{ product.name }}</a> {% if product.option %}
{% for option in product.option %} <br />
- <small>{{ option.name }} {{ option.value }}</small> {% endfor %}
{% endif %}
{% if product.recurring %} <br />
- <small>{{ text_recurring }} {{ product.recurring }}</small> {% endif %}</td>
<td class="text-right">x {{ product.quantity }}</td>
<td class="text-right">{{ product.total }}</td>
<td class="text-center"><button type="button" onclick="cart.remove('{{ product.cart_id }}');" title="{{ button_remove }}" class="btn btn-danger btn-xs"><i class="fa fa-times"></i></button></td>
</tr>
{% endfor %}
{% for voucher in vouchers %}
<tr>
<td class="text-center"></td>
<td class="text-left">{{ voucher.description }}</td>
<td class="text-right">x&nbsp;1</td>
<td class="text-right">{{ voucher.amount }}</td>
<td class="text-center text-danger"><button type="button" onclick="voucher.remove('{{ voucher.key }}');" title="{{ button_remove }}" class="btn btn-danger btn-xs"><i class="fa fa-times"></i></button></td>
</tr>
{% endfor %}
</table>
</li>
<li>
<div>
<table class="table table-bordered">
{% for total in totals %}
<tr>
<td class="text-right"><strong>{{ total.title }}</strong></td>
<td class="text-right">{{ total.text }}</td>
</tr>
{% endfor %}
</table>
<p class="text-right"><a href="{{ cart }}"><strong><i class="fa fa-shopping-cart"></i> {{ text_cart }}</strong></a>&nbsp;&nbsp;&nbsp;<a href="{{ checkout }}"><strong><i class="fa fa-share"></i> {{ text_checkout }}</strong></a></p>
</div>
</li>
{% else %}
<li>
<p class="text-center">{{ text_empty }}</p>
</li>
{% endif %}
</ul>
</div>


<!-- end snippet -->

When I am adding all of cart code from cart form directly here in place of {{ cart }} it's working fine but some fonts and javascript are not working. Can someone please help me to fix this ?

Newbie

Posts

Joined
Sat Jun 12, 2021 2:31 pm

Post by straightlight » Sat Jun 12, 2021 5:24 pm

jazaibhussain wrote:
Sat Jun 12, 2021 2:35 pm
I am working on OpenCart 3.0. I need to add cart in footer. This code works perfectly in old opencart version(TPL) but not working in (TWIG). Code is as below.
<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->
//Code in Stylesheet
#bottom_cart_section {
position:fixed;
bottom:0px;
height:100px;
width:100%;
background-color:#FFF;
box-shadow:0px 0px 12px 1px #CCC;
padding: 10px 5%;
z-index:95;
}
<!-- end snippet -->

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->


//Code on footer form
<div id="bottom_cart_section">
{{ cart }}
</div>

<!-- end snippet -->

Cart code is as below

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

<div id="cart" class="btn-group btn-block">
<button type="button" data-toggle="dropdown" data-loading-text="{{ text_loading }}" class="btn btn-inverse btn-block btn-lg dropdown-toggle"><i class="fa fa-shopping-cart"></i> <span id="cart-total">{{ text_items }}</span></button>
<ul class="dropdown-menu pull-right">
{% if products or vouchers %}
<li>
<table class="table table-striped">
{% for product in products %}
<tr>
<td class="text-center">{% if product.thumb %} <a href="{{ product.href }}"><img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-thumbnail" /></a> {% endif %}</td>
<td class="text-left"><a href="{{ product.href }}">{{ product.name }}</a> {% if product.option %}
{% for option in product.option %} <br />
- <small>{{ option.name }} {{ option.value }}</small> {% endfor %}
{% endif %}
{% if product.recurring %} <br />
- <small>{{ text_recurring }} {{ product.recurring }}</small> {% endif %}</td>
<td class="text-right">x {{ product.quantity }}</td>
<td class="text-right">{{ product.total }}</td>
<td class="text-center"><button type="button" onclick="cart.remove('{{ product.cart_id }}');" title="{{ button_remove }}" class="btn btn-danger btn-xs"><i class="fa fa-times"></i></button></td>
</tr>
{% endfor %}
{% for voucher in vouchers %}
<tr>
<td class="text-center"></td>
<td class="text-left">{{ voucher.description }}</td>
<td class="text-right">x&nbsp;1</td>
<td class="text-right">{{ voucher.amount }}</td>
<td class="text-center text-danger"><button type="button" onclick="voucher.remove('{{ voucher.key }}');" title="{{ button_remove }}" class="btn btn-danger btn-xs"><i class="fa fa-times"></i></button></td>
</tr>
{% endfor %}
</table>
</li>
<li>
<div>
<table class="table table-bordered">
{% for total in totals %}
<tr>
<td class="text-right"><strong>{{ total.title }}</strong></td>
<td class="text-right">{{ total.text }}</td>
</tr>
{% endfor %}
</table>
<p class="text-right"><a href="{{ cart }}"><strong><i class="fa fa-shopping-cart"></i> {{ text_cart }}</strong></a>&nbsp;&nbsp;&nbsp;<a href="{{ checkout }}"><strong><i class="fa fa-share"></i> {{ text_checkout }}</strong></a></p>
</div>
</li>
{% else %}
<li>
<p class="text-center">{{ text_empty }}</p>
</li>
{% endif %}
</ul>
</div>


<!-- end snippet -->

When I am adding all of cart code from cart form directly here in place of {{ cart }} it's working fine but some fonts and javascript are not working. Can someone please help me to fix this ?
4 digits. Lacks. Commercial Support request.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 79 guests