mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 07:29:22 +00:00
feat: coupon_code and referral_sales_partner functionality
This commit is contained in:
committed by
Rohit Waghchaure
parent
0bb99c15e5
commit
74dc3c99de
@@ -20,6 +20,7 @@ $.extend(shopping_cart, {
|
||||
shopping_cart.bind_change_qty();
|
||||
shopping_cart.bind_change_notes();
|
||||
shopping_cart.bind_dropdown_cart_buttons();
|
||||
shopping_cart.bind_coupon_code();
|
||||
},
|
||||
|
||||
bind_address_select: function() {
|
||||
@@ -193,6 +194,29 @@ $.extend(shopping_cart, {
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
bind_coupon_code: function() {
|
||||
$(".bt-coupon").on("click", function() {
|
||||
shopping_cart.apply_coupon_code(this);
|
||||
});
|
||||
},
|
||||
|
||||
apply_coupon_code: function(btn) {
|
||||
return frappe.call({
|
||||
type: "POST",
|
||||
method: "erpnext.shopping_cart.cart.apply_coupon_code",
|
||||
btn: btn,
|
||||
args : {
|
||||
applied_code : $('.txtcoupon').val(),
|
||||
applied_referral_sales_partner: $('.txtreferral_sales_partner').val()
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r && r.message){
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,16 @@
|
||||
{% set select_address = True %}
|
||||
{% endif %}
|
||||
|
||||
{% set show_coupon_code = frappe.db.get_single_value('Shopping Cart Settings', 'show_apply_coupon_code_in_website') %}
|
||||
{% if show_coupon_code == 1%}
|
||||
<div class="mb-3">
|
||||
<div class="row no-gutters">
|
||||
<input type="text" class="txtcoupon form-control mr-3 w-25" placeholder="Enter Coupon Code" name="txtcouponcode" ></input>
|
||||
<button class="btn btn-primary btn-sm bt-coupon">{{ _("Apply Coupon Code") }}</button>
|
||||
<input type="hidden" class="txtreferral_sales_partner" placeholder="Enter Sales Partner" name="txtreferral_sales_partner" type="text"></input>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="mb-3" data-section="shipping-address">
|
||||
<h6 class="text-uppercase">{{ _("Shipping Address") }}</h6>
|
||||
<div class="row no-gutters" data-fieldname="shipping_address_name">
|
||||
|
||||
@@ -22,6 +22,71 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if doc.doctype == 'Quotation' %}
|
||||
{% if doc.coupon_code %}
|
||||
<tr>
|
||||
<th class="text-right" colspan="2">
|
||||
{{ _("Discount") }}
|
||||
</th>
|
||||
<th class="text-right tot_quotation_discount">
|
||||
{% set tot_quotation_discount = [] %}
|
||||
{%- for item in doc.items -%}
|
||||
{% if tot_quotation_discount.append((((item.price_list_rate * item.qty)
|
||||
* item.discount_percentage) / 100)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{{ frappe.utils.fmt_money((tot_quotation_discount | sum),currency=doc.currency) }}
|
||||
</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if doc.doctype == 'Sales Order' %}
|
||||
{% if doc.coupon_code %}
|
||||
<tr>
|
||||
<th class="text-right" colspan="2">
|
||||
{{ _("Total Amount") }}
|
||||
</th>
|
||||
<th class="text-right">
|
||||
<span>
|
||||
{% set total_amount = [] %}
|
||||
{%- for item in doc.items -%}
|
||||
{% if total_amount.append((item.price_list_rate * item.qty)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{{ frappe.utils.fmt_money((total_amount | sum),currency=doc.currency) }}
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-right" colspan="2">
|
||||
{{ _("Applied Coupon Code") }}
|
||||
</th>
|
||||
<th class="text-right">
|
||||
<span>
|
||||
{%- for row in frappe.get_all(doctype="Coupon Code",
|
||||
fields=["coupon_code"], filters={ "name":doc.coupon_code}) -%}
|
||||
<span>{{ row.coupon_code }}</span>
|
||||
{% endfor %}
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-right" colspan="2">
|
||||
{{ _("Discount") }}
|
||||
</th>
|
||||
<th class="text-right">
|
||||
<span>
|
||||
{% set tot_SO_discount = [] %}
|
||||
{%- for item in doc.items -%}
|
||||
{% if tot_SO_discount.append((((item.price_list_rate * item.qty)
|
||||
* item.discount_percentage) / 100)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{{ frappe.utils.fmt_money((tot_SO_discount | sum),currency=doc.currency) }}
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<tr>
|
||||
<th class="text-right" colspan="2">
|
||||
{{ _("Grand Total") }}
|
||||
|
||||
Reference in New Issue
Block a user