2019-03-19 06:18:32 +00:00
|
|
|
{% if shopping_cart and shopping_cart.cart_settings.enabled %}
|
|
|
|
|
|
|
|
{% set cart_settings = shopping_cart.cart_settings %}
|
|
|
|
{% set product_info = shopping_cart.product_info %}
|
|
|
|
|
|
|
|
<div class="item-cart row mt-2" data-variant-item-code="{{ item_code }}">
|
|
|
|
<div class="col-md-12">
|
2021-03-22 10:47:59 +00:00
|
|
|
<!-- Price and Availability -->
|
2019-03-19 06:18:32 +00:00
|
|
|
{% if cart_settings.show_price and product_info.price %}
|
2020-12-24 06:10:33 +00:00
|
|
|
<div class="product-price">
|
2019-03-19 06:18:32 +00:00
|
|
|
{{ product_info.price.formatted_price_sales_uom }}
|
2020-12-24 06:10:33 +00:00
|
|
|
<small class="formatted-price">({{ product_info.price.formatted_price }} / {{ product_info.uom }})</small>
|
|
|
|
</div>
|
2020-09-24 05:49:32 +00:00
|
|
|
{% else %}
|
2021-04-13 10:16:01 +00:00
|
|
|
{{ _("UOM") }} : {{ product_info.uom }}
|
2019-03-19 06:18:32 +00:00
|
|
|
{% endif %}
|
2020-09-24 05:49:32 +00:00
|
|
|
|
2019-03-19 06:18:32 +00:00
|
|
|
{% if cart_settings.show_stock_availability %}
|
|
|
|
<div>
|
|
|
|
{% if product_info.in_stock == 0 %}
|
2020-12-24 06:10:33 +00:00
|
|
|
<span class="text-danger no-stock">
|
2019-03-19 06:18:32 +00:00
|
|
|
{{ _('Not in stock') }}
|
|
|
|
</span>
|
|
|
|
{% elif product_info.in_stock == 1 %}
|
2020-12-24 06:10:33 +00:00
|
|
|
<span class="text-success has-stock">
|
2019-03-19 06:18:32 +00:00
|
|
|
{{ _('In stock') }}
|
|
|
|
{% if product_info.show_stock_qty and product_info.stock_qty %}
|
|
|
|
({{ product_info.stock_qty[0][0] }})
|
|
|
|
{% endif %}
|
|
|
|
</span>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-03-22 10:47:59 +00:00
|
|
|
|
|
|
|
<!-- Add to Cart / View in Cart, Contact Us -->
|
2021-01-20 12:17:25 +00:00
|
|
|
<div class="mt-5 mb-5">
|
2021-03-22 10:47:59 +00:00
|
|
|
<div style="display: flex;" class="mb-4">
|
|
|
|
<!-- Add to Cart -->
|
|
|
|
{% if product_info.price and (cart_settings.allow_items_not_in_stock or product_info.in_stock) %}
|
2020-08-31 08:30:27 +00:00
|
|
|
<a href="/cart"
|
2021-03-22 10:47:59 +00:00
|
|
|
class="btn btn-light btn-view-in-cart hidden mr-2"
|
2020-08-31 08:30:27 +00:00
|
|
|
role="button"
|
|
|
|
>
|
|
|
|
{{ _("View in Cart") }}
|
|
|
|
</a>
|
|
|
|
<button
|
|
|
|
data-item-code="{{item_code}}"
|
2021-03-22 10:47:59 +00:00
|
|
|
class="btn btn-primary btn-add-to-cart w-50 mr-2"
|
2020-08-31 08:30:27 +00:00
|
|
|
>
|
2021-01-20 12:17:25 +00:00
|
|
|
<span class="mr-2">
|
|
|
|
<svg class="icon icon-md">
|
|
|
|
<use href="#icon-assets"></use>
|
|
|
|
</svg>
|
|
|
|
</span>
|
2020-08-31 08:30:27 +00:00
|
|
|
{{ _("Add to Cart") }}
|
|
|
|
</button>
|
2021-03-22 10:47:59 +00:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<!-- Add to Wishlist -->
|
2021-03-25 06:22:50 +00:00
|
|
|
{% if cart_settings.enable_wishlist %}
|
|
|
|
<a href="/wishlist"
|
|
|
|
class="btn btn-view-in-wishlist hidden"
|
|
|
|
role="button"
|
|
|
|
>
|
|
|
|
<span class="mr-2">
|
|
|
|
<svg class="icon icon-md">
|
|
|
|
<use href="#icon-heart"></use>
|
|
|
|
</svg>
|
|
|
|
</span>
|
|
|
|
{{ _("View in Wishlist") }}
|
|
|
|
</a>
|
2021-03-22 10:47:59 +00:00
|
|
|
|
2021-03-25 06:22:50 +00:00
|
|
|
{% set price = product_info.get("price") or {} %}
|
|
|
|
<button
|
2021-03-22 10:47:59 +00:00
|
|
|
data-item-code="{{item_code}}"
|
|
|
|
data-price="{{ price.get('price_list_rate') or 0}}"
|
|
|
|
data-formatted-price="{{ price.get('formatted_price') or 0 }}"
|
|
|
|
class="btn btn-add-to-wishlist"
|
|
|
|
>
|
2021-03-25 06:22:50 +00:00
|
|
|
<span class="mr-2">
|
|
|
|
<svg class="icon icon-md">
|
|
|
|
<use href="#icon-heart"></use>
|
|
|
|
</svg>
|
|
|
|
</span>
|
|
|
|
{{ _("Add to Wishlist") }}
|
|
|
|
</button>
|
|
|
|
{% endif %}
|
2021-03-22 10:47:59 +00:00
|
|
|
</div>
|
|
|
|
|
2021-03-25 06:22:50 +00:00
|
|
|
<!-- Contact Us -->
|
2020-08-31 08:30:27 +00:00
|
|
|
{% if cart_settings.show_contact_us_button %}
|
|
|
|
{% include "templates/generators/item/item_inquiry.html" %}
|
|
|
|
{% endif %}
|
2019-03-19 06:18:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
frappe.ready(() => {
|
|
|
|
$('.page_content').on('click', '.btn-add-to-cart', (e) => {
|
2021-03-22 10:47:59 +00:00
|
|
|
// Bind action on add to cart button
|
2019-03-19 06:18:32 +00:00
|
|
|
const $btn = $(e.currentTarget);
|
|
|
|
$btn.prop('disabled', true);
|
|
|
|
const item_code = $btn.data('item-code');
|
|
|
|
erpnext.shopping_cart.update_cart({
|
|
|
|
item_code,
|
|
|
|
qty: 1,
|
|
|
|
callback(r) {
|
|
|
|
$btn.prop('disabled', false);
|
|
|
|
if (r.message) {
|
|
|
|
$('.btn-add-to-cart, .btn-view-in-cart').toggleClass('hidden');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2021-03-22 10:47:59 +00:00
|
|
|
|
|
|
|
$('.page_content').on('click', '.btn-add-to-wishlist', (e) => {
|
|
|
|
// Bind action on wishlist button
|
|
|
|
const $btn = $(e.currentTarget);
|
|
|
|
$btn.prop('disabled', true);
|
|
|
|
|
|
|
|
let args = {
|
|
|
|
item_code: $btn.data('item-code'),
|
|
|
|
price: $btn.data('price'),
|
|
|
|
formatted_price: $btn.data('formatted-price')
|
|
|
|
};
|
|
|
|
let failure_action = function() {
|
|
|
|
$btn.prop('disabled', false);
|
|
|
|
};
|
|
|
|
let success_action = function() {
|
|
|
|
$btn.prop('disabled', false);
|
|
|
|
erpnext.wishlist.set_wishlist_count();
|
|
|
|
$('.btn-add-to-wishlist, .btn-view-in-wishlist').toggleClass('hidden');
|
|
|
|
|
|
|
|
};
|
|
|
|
erpnext.wishlist.add_remove_from_wishlist("add", args, success_action, failure_action);
|
|
|
|
});
|
2019-03-19 06:18:32 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2019-09-12 05:50:55 +00:00
|
|
|
{% endif %}
|