[ADD] ensan_website_Sale

This commit is contained in:
Abdurrahman Saber 2025-04-17 05:44:19 +02:00
parent 7bae571093
commit 4e33630002
43 changed files with 14928 additions and 15182 deletions

View File

@ -9,6 +9,7 @@ class ProductTemplate_Inherit(models.Model):
_inherit = 'product.template'
is_donation = fields.Boolean("Is Donation Product?", default=True)
is_gift = fields.Boolean("Is Gift Product?", default=False)
donation_type = fields.Selection(
[
('Free Amount', 'Free Amount'),
@ -198,3 +199,4 @@ class ProductProduct_Inherit(models.Model):
_inherit = 'product.product'
is_donation = fields.Boolean('Is Donation Variant?', related="product_tmpl_id.is_donation")
is_gift = fields.Boolean("Is Gift Product?", related="product_tmpl_id.is_gift")

View File

@ -0,0 +1 @@
from . import controllers

View File

@ -0,0 +1,17 @@
{
'name': 'Ensan Website Sale',
'version': '14.0',
'description': '',
'summary': '',
'author': '',
'website': '',
'license': 'LGPL-3',
'category': '',
'depends': [
'website_sale',
'payment_hyperpay',
'payment_applepay',
'ensan_sale_management'
],
'data': ['views/templates.xml', 'views/assets.xml'],
}

View File

@ -17,6 +17,24 @@ class WebsiteSaleExtended(WebsiteSale):
response = super(WebsiteSaleExtended, self).checkout(**post)
response.qcontext.update({'hide_quick_donation': True})
return response
@http.route()
def confirm_order(self, **post):
order = request.website.sale_get_order()
redirection = self.checkout_redirection(order) or self.checkout_check_address(order)
if redirection:
return redirection
order.onchange_partner_shipping_id()
order.order_line._compute_tax_id()
request.session['sale_last_order_id'] = order.id
# request.website.sale_get_order(update_pricelist=True)
extra_step = request.website.viewref('website_sale.extra_info_option')
if extra_step.active:
return request.redirect("/shop/extra_info")
return request.redirect("/shop/payment")
@http.route()
def payment(self, **post):
@ -35,11 +53,6 @@ class WebsiteSaleExtended(WebsiteSale):
response = super(WebsiteSaleExtended, self).product(product, category, search, **kwargs)
response.qcontext.update({'hide_quick_donation': True, 'product_details': True})
return response
@http.route()
def shop(self, page=0, category=None, search='', min_price=0.0, max_price=0.0, ppg=False, **post):
response = super().shop(page=page, category=category, search=search, min_price=min_price, max_price=max_price, ppg=ppg, **post)
return response
def check_mobile_number_validation(self, phone):
if phone[0] == '+' and phone[1] != '0':

View File

Before

Width:  |  Height:  |  Size: 833 B

After

Width:  |  Height:  |  Size: 833 B

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 263 B

After

Width:  |  Height:  |  Size: 263 B

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,57 @@
odoo.define('ensan_website_sale.payment', require => {
'use strict';
const publicWidget = require('web.public.widget');
const paymentForm = require('payment.payment_form');
const websiteSaleextraMixin = {
_adaptPayButton: function() {
this._super();
this.checkMobileNumberFormat();
},
checkMobileNumberFormat: function() {
const mobileInput = this.$('#order_mobile_number');
const mobileRegex = /^(?:(\+966|00966|0)?5[0-9]{8}|5[0-9]{8})$/;
if (mobileRegex.test(mobileInput.val())) {
mobileInput.removeClass('is-invalid').addClass('is-valid');
$("#o_payment_form_pay").attr('disabled', false);
} else {
mobileInput.removeClass('is-valid').addClass('is-invalid');
$("#o_payment_form_pay").attr('disabled', true);
}
},
};
paymentForm.include(
Object.assign({}, websiteSaleextraMixin, {
events: _.extend(paymentForm.prototype.events, {
'input #order_mobile_number':'checkMobileNumberFormat'
}),
payEvent: function (ev) {
this._rpc({
route: '/customer/data/save',
params: {
extra_name: this.$('#order_name').val(),
extra_mobile: this.$('#order_mobile_number').val(),
}
}).catch(error => {
console.error(error);
});
this._super(ev);
}
})
);
publicWidget.registry.WebsiteSaleExtraField = publicWidget.Widget.extend(
Object.assign({}, websiteSaleextraMixin, {
selector: '.js_payment',
events: {
'input #order_mobile_number':'checkMobileNumberFormat'
},
})
);
});

View File

@ -0,0 +1,114 @@
odoo.define("ensan_website_sale.product_details_gifts", function (require) {
"use strict";
var publicWidget = require("web.public.widget");
publicWidget.registry.WebsiteSale.include({
_submitForm() {
const $product = $("#product_detail");
const product_id = $product.find("input[name=product_id]").val();
const gift_box_list = [];
if ($product.find("#sendAsGiftCheckbox:checked").length > 0) {
$product.find("#gift-details #gifteeContainer .gifteeBoxDetails").each(function () {
gift_box_list.push({
product_id: product_id,
donator_name: $(this).find("input.input-gifteeName").val(),
donator_mobile_number: $(this).find("select.country-code").val() + $(this).find("input.input-gifteeNumber").val(),
donated_amount: ArabictoEnglishNumber($(this).find("input.donation-input-amt").val()),
});
});
}
this.rootProduct.donators_ids = JSON.stringify(gift_box_list);
return this._super(...arguments);
},
});
publicWidget.registry.ProductDetailsGifts = publicWidget.Widget.extend({
selector: "#product_details_gifts_container",
events: {
"click .removeGiftee": "_donation_remove_gift_container",
"click #addGiftee": "_donation_add_gift_container",
"click .gift-input-amount": "_donation_gift_input_amt",
"change #sendAsGiftCheckbox": "_donation_toggle_gift_container",
},
_donation_remove_gift_container(ev) {
$(ev.target).closest(".gifteeBoxDetails").remove();
this.$("input.donation-input-amt").trigger("change");
},
_donation_add_gift_container() {
var new_box = $(".donation-product-detail-layout .gifteeBoxDetails:last").clone(true, true);
new_box.find(".removeGiftee").removeClass("o_hidden");
new_box.find("input").each(function () {
var temp_id = $(this).prop("id");
var temp_id_list = temp_id.split("-");
if (temp_id_list[0] == "amount") {
$(this).prop("id", temp_id_list[0].concat("-" + (parseInt(temp_id_list[1]) + 3)));
$(this).prop("checked", false);
} else {
$(this).prop("id", temp_id_list[0].concat("-" + (parseInt(temp_id_list[1]) + 1)));
if (!$(this).hasClass("donation-input-amt")) {
$(this).prop("value", "");
}
}
var temp_name = $(this).prop("name");
var temp_name_list = temp_name.split("-");
$(this).prop("name", temp_name_list[0].concat("-" + (parseInt(temp_name_list[1]) + 1)));
});
new_box.find("label").each(function () {
var temp_label = $(this).prop("for");
var temp_label_list = temp_label.split("-");
if (temp_label_list[0] == "amount") {
$(this).prop("for", temp_label_list[0].concat("-" + (parseInt(temp_label_list[1]) + 3)));
} else {
$(this).prop("for", temp_label_list[0].concat("-" + (parseInt(temp_label_list[1]) + 1)));
}
});
var temp_id = new_box.prop("id");
var temp_id_list = temp_id.split("-");
new_box.prop("id", temp_id_list[0].concat("-" + (parseInt(temp_id_list[1]) + 1)));
new_box.appendTo(".donation-product-detail-layout #gifteeContainer");
this.$("input.donation-input-amt").trigger("change");
},
_donation_gift_input_amt(ev) {
$(ev.target).parent().parent().parent().find("input.AnotherAmountAdd").val(ev.target.value);
this.$("input.donation-input-amt").trigger("change");
},
_donation_toggle_gift_container(ev) {
if (ev.target.checked) {
this.$("#gift-details").show();
this.$("#remove_gift_card:first").addClass("o_hidden");
this.$(".ProhectDetailsSubBox").addClass("is-disabled");
this.$(".ProhectDetailsSubBox").find("input[inputmode=numeric]").val("");
} else {
this.$("#gift-details input.donation-input-amt").val("");
this.$("#gift-details").hide();
this.$(".ProhectDetailsSubBox").removeClass("is-disabled");
}
this.$("input.donation-input-amt").trigger("change");
},
_is_all_input_valid() {
if (this.$("#sendAsGiftCheckbox:checked").length > 0) {
var is_valid = true;
this.$("#gift-details input").each(function () {
if (!$(this).val()) {
$(this).addClass("is-invalid");
$(this).removeClass("is-valid");
is_valid = false;
} else {
$(this).removeClass("is-invalid");
$(this).addClass("is-valid");
}
});
if (!is_valid) {
return false;
}
}
return true;
},
});
});

View File

@ -1,4 +1,4 @@
odoo.define('p_donation_theme.quick_donation_hyperpay', function(require) {
odoo.define('ensan_website_sale.quick_donation_hyperpay', function(require) {
"use strict";
var publicWidget = require('web.public.widget');
@ -125,7 +125,7 @@ odoo.define('p_donation_theme.quick_donation_hyperpay', function(require) {
var self = this;
try {
var $quick_donation_tag = this.quick_donation.find("#quick-donation-3")
var style_css = '<link rel="stylesheet" href="' + base_url + '/p_donation_theme/static/src/scss/hyperpay_quick_donation.scss" />'
var style_css = '<link rel="stylesheet" href="' + base_url + '/ensan_website_sale/static/src/scss/hyperpay_quick_donation.scss" />'
var script = '<script async src="' + domain + '/v1/paymentWidgets.js?checkoutId=' + checkoutId + '"></script>'
var js_script = '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>'
var shopperResultUrlTag = '<form action="' + base_url + '/payment/hyperpay/result?acq=' + acq + '" class="paymentWidgets" data-brands="' + data_brands + '"></form>'
@ -149,7 +149,8 @@ odoo.define('p_donation_theme.quick_donation_hyperpay', function(require) {
},
_initBlockUI: function() {
if (this.quick_donation.length > 0) {
this.quick_donation.find("#qn-spinner").removeClass('o_hidden')
this.quick_donation.find("#qn-spinner").removeClass('o_hidden');
this.quick_donation.find("#qn-spinner").addClass('d-flex');
this.quick_donation.find("#qd-options").addClass("blur_disabled");
}
},
@ -225,6 +226,7 @@ odoo.define('p_donation_theme.quick_donation_hyperpay', function(require) {
}
else {
$('#quick-donation-widget #qn-failure').removeClass('o_hidden');
$('#quick-donation-widget #qn-failure').addClass('d-flex');
}
quick_pay_detail['product_id'] = product_id;
quick_pay_detail['acquire_id'] = acquire_id[0].dataset.acquireId;
@ -241,6 +243,7 @@ odoo.define('p_donation_theme.quick_donation_hyperpay', function(require) {
}
else {
$('#quick-donation-widget #qn-failure').removeClass('o_hidden');
$('#quick-donation-widget #qn-failure').addClass('d-flex');
}
});
}

View File

@ -0,0 +1,191 @@
odoo.define('ensan_website_sale.product-gift-card', function (require) {
"use strict";
require('web.dom_ready');
var publicWidget = require('web.public.widget');
const {qweb} = require('web.core');
function ArabictoEnglishNumber(strNum) {
var ar = '٠١٢٣٤٥٦٧٨٩'.split('');
var en = '0123456789'.split('');
strNum = strNum.replace(/[٠١٢٣٤٥٦٧٨٩]/g, x => en[ar.indexOf(x)]);
strNum = strNum.replace(/[^\d]/g, '');
return strNum;
}
publicWidget.registry.WebsiteSale.include({
events: _.extend({}, publicWidget.registry.WebsiteSale.prototype.events || {}, {
'change .update_amount': '_onchange_quantity_price',
'click .temp-donate-now': 'async _temp_donate_now',
'click .temp-add-cart': 'async _temp_add_cart',
'click .single-amount': '_update_default_amt',
'click .donation_share_btn': '_open_share_popup',
'change input.donation-input-amt': '_update_apple_pay_amount',
'input form input[name="add_qty"]': '_convert_arabic_to_english',
'input input.only-number, input.input-gifteeNumber, input.number-input, input.update_amount': '_convert_arabic_to_english'
}),
xmlDependencies: ["/ensan_website_sale/static/src/xml/donation.xml"],
_convert_arabic_to_english(ev) {
ev.currentTarget.value = ArabictoEnglishNumber(ev.currentTarget.value)
},
async start() {
await this._super(...arguments);
const amounts = this.$('.single-amount');
const fixedQty = this.$('#fixedqtyinput-1');
const $amountEl = this.$('input.donation-input-amt');
if (amounts.length > 0) {
$amountEl.val(amounts.get(0).dataset.amount);
} else{
$amountEl.val(fixedQty.data('price'));
}
},
_update_apple_pay_amount() {
let total = 0;
const isGift = this.$('#sendAsGiftCheckbox').is(':checked');
if (isGift) {
this.$('input.gift-donation-amount').each(function() {
const value = $(this).val();
if (value) {
total += parseFloat(value, 10) || 0;
}
});
} else {
total = this.$('input.personal-donation-amount').val() || 0;
}
const event = new CustomEvent('applePayAmountUpdate', {
detail: { amount: total }
});
document.dispatchEvent(event);
},
_handleAdd: function ($form) {
if ($form.length == 0) {
$form = this.$("#add_to_cart, .o_we_buy_now, #products_grid .o_wsale_product_btn .a-submit").closest('form');
}
return this._super($form);
},
_onchange_quantity_price(ev) {
var price = ev.currentTarget.dataset.price;
var qty = ArabictoEnglishNumber(ev.target.value);
const $amountEl = $(ev.target).parent().parent().parent().find("input[inputmode=numeric]");
$amountEl.val(price*qty);
$amountEl.trigger('change');
},
_open_share_popup(ev) {
ev.preventDefault()
ev.stopPropagation()
var share_model = document.createElement("div");
share_model.classList.add("donation-product-detail-layout")
$(qweb.render("product_share_modal",{website_url :ev.currentTarget.dataset.website_url,url: encodeURIComponent(ev.currentTarget.dataset.website_url),msg: encodeURIComponent("Thanks For your Donation")})).appendTo($(share_model));
$(share_model).appendTo($(ev.currentTarget).parent());
$('#action_product_share_modal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var modal = $(this)
var input_url = modal.find('.share-link input')
modal.find('.share-link #copy_clip').on("click", function(ev){
ev.preventDefault()
ev.stopPropagation()
input_url.select();
navigator.clipboard.writeText(input_url.val());
});
modal.find('#toggle-share-modal').on("click", function() {
modal.parent().remove();
})
})
$("#action_product_share_modal").modal({backdrop: true});
$("#action_product_share_modal").modal('show');
$('#action_product_share_modal').on('hidden.bs.modal', function () {
$('#action_product_share_modal').parent().remove();
});
},
async _temp_add_cart() {
if (this._is_all_input_valid()) {
this._donation_total_amount();
await this.$('#add_to_cart').click();
}
},
async _temp_donate_now() {
if (this._is_all_input_valid()) {
this._donation_total_amount();
await this.$('#buy_now').click();
}
},
_donation_total_amount() {
let total_amt = 0
var fixed_qty = this.$("input.update_amount");
if (fixed_qty.length > 0) {
fixed_qty.each(function() {
if ($(this).val()) {
total_amt = total_amt + parseFloat(ArabictoEnglishNumber($(this).val()))
}
});
} else {
this.$("input.donation-input-amt:visible").each(function() {
if ($(this).val()) {
total_amt = total_amt + parseFloat(ArabictoEnglishNumber($(this).val()))
}
});
}
this.$("form input[name=add_qty]").val(total_amt)
this.$("form input[name=add_qty]").trigger("change")
},
_update_default_amt(ev) {
const $amountEl = $("input.input-another-amount");
$amountEl.val(ev.currentTarget.dataset.amount);
$amountEl.trigger("change");
},
_is_all_input_valid() {
if($("#sendAsGiftCheckbox:checked").length > 0) {
var is_valid = true;
$("#gift-details input").each(function() {
if(!$(this).val()){
$(this).addClass("is-invalid");
$(this).removeClass("is-valid");
is_valid = false
} else{
$(this).removeClass("is-invalid");
$(this).addClass("is-valid");
}
});
if (!is_valid) {
return false
}
}
else {
var is_valid = true;
$(".ProhectDetailsSubBox input").each(function() {
if(!$(this).val() || $(this).val() == 0){
$(this).addClass("is-invalid");
$(this).removeClass("is-valid");
is_valid = false
} else{
$(this).removeClass("is-invalid");
$(this).addClass("is-valid");
}
});
if (!is_valid) {
return false
}
}
return true
}
});
})

View File

@ -1,10 +1,10 @@
odoo.define('p_donation_theme.website_sale_tracking', function (require) {
odoo.define('ensan_website_sale.website_sale_tracking', function (require) {
'use strict';
const tracking = require('website_sale.tracking');
let publicWidget = require('web.public.widget');
tracking.include({
events: _.extend(tracking.prototype.events, {
publicWidget.registry.websiteSaleTracking.include({
events: _.extend(publicWidget.registry.websiteSaleTracking.prototype.events, {
'click a[href="/shop/checkout?express=1"]': '_onCheckoutStart',
}),
_onCheckoutStart: function (ev) {
@ -15,13 +15,13 @@ odoo.define('p_donation_theme.website_sale_tracking', function (require) {
window.location.href = ev.currentTarget.href;
}, 1000);
},
_onAddProductIntoCart: function (ev) {
this._super.apply(this, arguments);
const $product = $(ev.target.closest('form'));
const productTrackingInfo = JSON.parse($product.find('input[name="product-tracking-info"]').val());
productTrackingInfo.quantity = 1;
$product.trigger('add_to_cart_event', [productTrackingInfo]);
},
// _onAddProductIntoCart: function (ev) {
// this._super.apply(this, arguments);
// const $product = $(ev.target.closest('form'));
// const productTrackingInfo = JSON.parse($product.find('input[name="product-tracking-info"]').val());
// productTrackingInfo.quantity = 1;
// $product.trigger('add_to_cart_event', [productTrackingInfo]);
// },
_beginCheckoutGA4: function () {
let $productRows = $("table#cart_products tbody tr");
let items = $productRows.map(function() {
@ -39,5 +39,4 @@ odoo.define('p_donation_theme.website_sale_tracking', function (require) {
});
},
});
return tracking;
});

View File

@ -0,0 +1,64 @@
.apple-pay-button-container {
width: 100%;
height: 100%;
border: none;
overflow: hidden;
margin-bottom: 10px;
}
#payment_method {
position: relative;
.card {
margin-bottom: 45px;
}
.apple-pay-button-container {
position: absolute;
bottom: 40px;
height: auto;
margin: 0;
}
}
@media (max-width: 399.99px) {
#payment_method {
.apple-pay-button-container {
bottom: 40px;
}
}
}
// X-Small devices (portrait phones, less than 576px)
@media (min-width: 400px) and (max-width: 575.98px) {
#payment_method {
.apple-pay-button-container {
bottom: 40px;
}
}
}
// Small devices (landscape phones, less than 768px)
@media (min-width: 576px) and (max-width: 767.98px) {
#payment_method {
.apple-pay-button-container {
bottom: 40px;
}
}
}
// Medium devices (tablets, less than 992px)
@media (min-width: 768px) and (max-width: 991.98px) {
#payment_method {
.apple-pay-button-container {
bottom: 40px;
}
}
}
// Large devices (desktops, less than 1200px)
@media (min-width: 992px) and (max-width: 1199.98px) {
#payment_method {
.apple-pay-button-container {
bottom: 40px;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
<button id="toggle-share-modal" class="btn btn-close" type="button" aria-label="Close"/>
</div>
<div class="text-center mt-0 mb-1">
<img class="rounded mx-auto mb-5 d-block" src="/p_donation_theme/static/src/img/share-img.svg" alt="twitter-icon"/>
<img class="rounded mx-auto mb-5 d-block" src="/ensan_website_sale/static/src/img/share-img.svg" alt="twitter-icon"/>
<h5 id="share-modal-text" class="text-primary">Share via social media</h5>
</div>
<div class="share-link">
@ -23,21 +23,21 @@
t-att-href="'https://wa.me/?text=Thanks%20for%20your%20Donation%0A' + url"
data-action="share/whatsapp/share" target="_blank" rel="noopener">
<div>
<img loading="lazy" src="/p_donation_theme/static/src/img/whatsapp.svg" alt="Share via WhatsApp"/>
<img loading="lazy" src="/ensan_website_sale/static/src/img/whatsapp.svg" alt="Share via WhatsApp"/>
</div>
</a>
<a id="twitterShareLink" class="btn twitter"
t-att-href="'https://twitter.com/intent/tweet?url='+ url +'&amp;text='+msg"
target="_blank" rel="noopener">
<div>
<img loading="lazy" src="/p_donation_theme/static/src/img/twitter.svg" alt="Share via Twitter"/>
<img loading="lazy" src="/ensan_website_sale/static/src/img/twitter.svg" alt="Share via Twitter"/>
</div>
</a>
<a id="facebookShareLink" class="btn facebook"
t-att-href="'https://www.facebook.com/sharer/sharer.php?u=' + url +'&amp;quote='+ msg"
target="_blank" rel="noopener">
<div>
<img loading="lazy" src="/p_donation_theme/static/src/img/facebook.svg" alt="Share via Facebook"/>
<img loading="lazy" src="/ensan_website_sale/static/src/img/facebook.svg" alt="Share via Facebook"/>
</div>
</a>
</div>

View File

@ -0,0 +1,23 @@
<odoo>
<data>
<template id="assets_frontend" name="Frontend Assets" inherit_id="web.assets_frontend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/ensan_website_sale/static/src/scss/quick_donation.scss"/>
<link rel="stylesheet" type="text/scss" href="/ensan_website_sale/static/src/scss/applepay_checkout.scss"/>
<script type="text/javascript" src="/ensan_website_sale/static/src/js/checkout.js"/>
<script type="text/javascript" src="/ensan_website_sale/static/src/js/quick_donation.js"/>
<script type="text/javascript" src="/ensan_website_sale/static/src/js/website_sale_tracking.js"/>
<script type="text/javascript" src="/ensan_website_sale/static/src/js/product_details_gifts.js"/>
<script type="text/javascript" src="/ensan_website_sale/static/src/js/website_sale.js"/>
</xpath>
</template>
<template id="_assets_primary_variables" inherit_id="web._assets_primary_variables">
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/ensan_website_sale/static/src/scss/primary_variables.scss"/>
</xpath>
</template>
</data>
</odoo>

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,7 @@
'depends': ['base',
'website_sale',
'theme_prime',
'droggol_theme_common',
'payment_hyperpay',
'payment_applepay',
'ensan_sale_management'],
'droggol_theme_common'],
'data': [
'views/templates.xml',

View File

@ -1,99 +0,0 @@
odoo.define('p_donation_theme.payment', require => {
'use strict';
const publicWidget = require('web.public.widget');
const paymentForm = require('payment.payment_form');
function ArabictoEnglishNumber(strNum) {
var ar = '٠١٢٣٤٥٦٧٨٩'.split('');
var en = '0123456789'.split('');
strNum = strNum.replace(/[٠١٢٣٤٥٦٧٨٩]/g, x => en[ar.indexOf(x)]);
strNum = strNum.replace(/[^\d]/g, '');
return strNum;
}
const websiteSaleextraMixin = {
init: function() {
this._onCheck_extra_validation = _.debounce(this._onCheck_extra_validation, 100, true);
this._super(...arguments);
},
start: function() {
this.$submitButton = this.$('button[name="o_payment_submit_button"]');
this._adaptConfirmButton();
return this._super(...arguments);
},
_adaptConfirmButton: function() {
if (this.$('#order_mobile_number').length > 0) {
const disabledReasons = this.$submitButton.data('disabled_reasons') || {};
disabledReasons.omn = !this.$('#order_mobile_number').val();
this.$submitButton.data('disabled_reasons', disabledReasons);
}
},
};
paymentForm.include(
Object.assign({}, websiteSaleextraMixin, {
events: _.extend(paymentForm.prototype.events, {
'input #order_mobile_number':'_convert_arabic_to_english'
}),
_convert_arabic_to_english(ev) {
ev.currentTarget.value = ArabictoEnglishNumber(ev.currentTarget.value)
this._onCheck_extra_validation();
},
_isButtonReady: function() {
const disabledReasonFound = _.contains(
this.$submitButton.data('disabled_reasons'), true
);
return !disabledReasonFound && this._super();
},
_onCheck_extra_validation: function() {
this._adaptConfirmButton();
if (!this._enableButton()) {
this._disableButton(false);
}
},
payEvent: function (ev) {
this._rpc({
route: '/customer/data/save',
params: {
extra_name: this.$('#order_name').val(),
extra_mobile: this.$('#order_mobile_number').val(),
}
}).catch(error => {
console.error(error);
});
this._super(ev);
}
})
);
publicWidget.registry.WebsiteSaleExtraField = publicWidget.Widget.extend(
Object.assign({}, websiteSaleextraMixin, {
selector: 'div[name="o_website_sale_free_cart"]',
events: {
'change #order_mobile_number': '_onCheck_extra_validation',
},
start: function() {
this.$submitButton = this.$('button[name="o_payment_submit_button"]');
this._onCheck_extra_validation();
return this._super(...arguments);
},
_onCheck_extra_validation: function() {
this._adaptConfirmButton();
const disabledReasonFound = _.contains(
this.$submitButton.data('disabled_reasons'), true
);
this.$submitButton.prop('disabled', disabledReasonFound);
},
})
);
});

View File

@ -1,275 +0,0 @@
odoo.define('p_donation_theme.product-gift-card', function (require) {
"use strict";
require('web.dom_ready');
var publicWidget = require('web.public.widget');
const {qweb} = require('web.core');
function ArabictoEnglishNumber(strNum) {
var ar = '٠١٢٣٤٥٦٧٨٩'.split('');
var en = '0123456789'.split('');
strNum = strNum.replace(/[٠١٢٣٤٥٦٧٨٩]/g, x => en[ar.indexOf(x)]);
strNum = strNum.replace(/[^\d]/g, '');
return strNum;
}
publicWidget.registry.WebsiteSale.include({
events: _.extend({}, publicWidget.registry.WebsiteSale.prototype.events || {}, {
'change .update_amount': '_onchange_quantity_price',
'click .donation-product-detail-layout .temp-donate-now': 'async _temp_donate_now',
'click .donation-product-detail-layout .temp-add-cart': 'async _temp_add_cart',
'click .donation-product-detail-layout .gift-input-amount': '_donation_gift_input_amt',
'click .donation-product-detail-layout .removeGiftee': '_donation_remove_gift_container',
'click .donation-product-detail-layout #addGiftee': '_donation_add_gift_container',
'change .donation-product-detail-layout #sendAsGiftCheckbox': '_donation_toggle_gift_container',
'click .donation-product-detail-layout .single-amount': '_update_default_amt',
'click .donation_share_btn': '_open_share_popup',
'change .donation-product-detail-layout input.donation-input-amt': '_update_apple_pay_amount',
'input form input[name="add_qty"]': '_convert_arabic_to_english',
'input .donation-product-detail-layout input.only-number, .donation-product-detail-layout input.input-gifteeNumber, .donation-product-detail-layout input.number-input, .donation-product-detail-layout input.update_amount': '_convert_arabic_to_english'
}),
xmlDependencies: ["/p_donation_theme/static/src/xml/donation.xml"],
_convert_arabic_to_english(ev) {
ev.currentTarget.value = ArabictoEnglishNumber(ev.currentTarget.value)
},
async start() {
await this._super(...arguments);
const amounts = this.$('.donation-product-detail-layout .single-amount');
const fixedQty = this.$('#fixedqtyinput-1');
const $amountEl = this.$('input.donation-input-amt');
if (amounts.length > 0) {
$amountEl.val(amounts.get(0).dataset.amount);
} else{
$amountEl.val(fixedQty.data('price'));
}
},
_update_apple_pay_amount() {
let total = 0;
const isGift = this.$('#sendAsGiftCheckbox').is(':checked');
if (isGift) {
this.$('input.gift-donation-amount').each(function() {
const value = $(this).val();
if (value) {
total += parseFloat(value, 10) || 0;
}
});
} else {
total = this.$('input.personal-donation-amount').val() || 0;
}
const event = new CustomEvent('applePayAmountUpdate', {
detail: { amount: total }
});
document.dispatchEvent(event);
},
_submitForm() {
const params = this.rootProduct;
const $product = $('#product_detail');
const product_id = $product.find('input[name=product_id]').val()
const gift_box_list = [];
if ($product.find('#sendAsGiftCheckbox:checked').length > 0) {
$product.find('#gift-details #gifteeContainer .gifteeBoxDetails').each(function(){
gift_box_list.push({
product_id: product_id,
donator_name: $(this).find('input.input-gifteeName').val(),
donator_mobile_number: $(this).find('select.country-code').val() + $(this).find('input.input-gifteeNumber').val(),
donated_amount: ArabictoEnglishNumber($(this).find('input.donation-input-amt').val())
})
});
}
this.rootProduct.donators_ids = JSON.stringify(gift_box_list);
return this._super(...arguments);
},
_handleAdd: function ($form) {
if ($form.length == 0) {
$form = $("#add_to_cart, .o_we_buy_now, #products_grid .o_wsale_product_btn .a-submit").closest('form')
}
return this._super($form);
},
_onchange_quantity_price(ev) {
var price = ev.currentTarget.dataset.price;
var qty = ArabictoEnglishNumber(ev.target.value);
const $amountEl = $(ev.target).parent().parent().parent().find("input[inputmode=numeric]");
$amountEl.val(price*qty);
$amountEl.trigger('change');
},
_open_share_popup(ev) {
ev.preventDefault()
ev.stopPropagation()
var share_model = document.createElement("div");
share_model.classList.add("donation-product-detail-layout")
$(qweb.render("product_share_modal",{website_url :ev.currentTarget.dataset.website_url,url: encodeURIComponent(ev.currentTarget.dataset.website_url),msg: encodeURIComponent("Thanks For your Donation")})).appendTo($(share_model));
$(share_model).appendTo($(ev.currentTarget).parent());
$('#action_product_share_modal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var modal = $(this)
var input_url = modal.find('.share-link input')
modal.find('.share-link #copy_clip').on("click", function(ev){
ev.preventDefault()
ev.stopPropagation()
input_url.select();
navigator.clipboard.writeText(input_url.val());
});
modal.find('#toggle-share-modal').on("click", function() {
modal.parent().remove();
})
})
$("#action_product_share_modal").modal({backdrop: true});
$("#action_product_share_modal").modal('show');
$('#action_product_share_modal').on('hidden.bs.modal', function () {
$('#action_product_share_modal').parent().remove();
});
},
async _temp_add_cart() {
if (await this._is_all_input_valid()) {
await this._donation_total_amount();
await $('.donation-product-detail-layout .donate_product_add_cart')[0].click()
}
},
async _temp_donate_now() {
if (await this._is_all_input_valid()) {
await this._donation_total_amount();
await $('.donation-product-detail-layout .o_we_buy_now')[0].click();
}
},
_donation_gift_input_amt(ev) {
$(ev.target).parent().parent().parent().find("input.AnotherAmountAdd").val(ev.target.value)
this.$('input.donation-input-amt').trigger('change');
},
_donation_remove_gift_container(ev) {
$(ev.target).closest(".gifteeBoxDetails").remove();
this.$('input.donation-input-amt').trigger('change');
},
_donation_add_gift_container() {
var new_box = $(".donation-product-detail-layout .gifteeBoxDetails:last").clone(true, true)
new_box.find('.removeGiftee').removeClass("o_hidden");
new_box.find('input').each(function(){
var temp_id = $(this).prop("id")
var temp_id_list = temp_id.split('-')
if (temp_id_list[0] == "amount") {
$(this).prop('id', temp_id_list[0].concat('-' + (parseInt(temp_id_list[1]) + 3)) );
$(this).prop('checked', false)
}
else {
$(this).prop('id', temp_id_list[0].concat('-' + (parseInt(temp_id_list[1]) + 1)) );
if (!$(this).hasClass('donation-input-amt')){
$(this).prop('value', '');
}
}
var temp_name = $(this).prop("name")
var temp_name_list = temp_name.split('-')
$(this).prop('name', temp_name_list[0].concat('-' + (parseInt(temp_name_list[1]) + 1)) );
})
new_box.find('label').each(function(){
var temp_label = $(this).prop("for")
var temp_label_list = temp_label.split('-')
if (temp_label_list[0] == "amount") {
$(this).prop('for', temp_label_list[0].concat('-' + (parseInt(temp_label_list[1]) + 3)) );
}
else {
$(this).prop('for', temp_label_list[0].concat('-' + (parseInt(temp_label_list[1]) + 1)) );
}
});
var temp_id = new_box.prop("id")
var temp_id_list = temp_id.split('-')
new_box.prop('id', temp_id_list[0].concat('-' + (parseInt(temp_id_list[1]) + 1)) );
new_box.appendTo(".donation-product-detail-layout #gifteeContainer");
this.$('input.donation-input-amt').trigger('change');
},
_donation_toggle_gift_container(ev) {
if (ev.target.checked) {
$(".donation-product-detail-layout #gift-details" ).show();
$(".donation-product-detail-layout #remove_gift_card:first" ).addClass("o_hidden");
$(".donation-product-detail-layout .ProhectDetailsSubBox").addClass("is-disabled");
$(".donation-product-detail-layout .ProhectDetailsSubBox").find("input[inputmode=numeric]").val('')
}
else {
this.$('#gift-details input.donation-input-amt').val('');
$(".donation-product-detail-layout #gift-details" ).hide();
$(".donation-product-detail-layout .ProhectDetailsSubBox").removeClass("is-disabled");
}
this.$('input.donation-input-amt').trigger('change');
},
async _donation_total_amount() {
let total_amt = 0
var fixed_qty = $(".donation-product-detail-layout input.update_amount")
if (fixed_qty.length > 0) {
fixed_qty.each(function() {
if ($(this).val()) {
total_amt = total_amt + parseFloat(ArabictoEnglishNumber($(this).val()))
}
});
} else {
$(".donation-product-detail-layout input.donation-input-amt").each(function() {
if ($(this).val()) {
total_amt = total_amt + parseFloat(ArabictoEnglishNumber($(this).val()))
}
});
}
$(".donation-product-detail-layout form input[name=add_qty]").val(total_amt)
$(".donation-product-detail-layout form input[name=add_qty]").trigger("change")
},
_update_default_amt(ev) {
const $amountEl = $("input.input-another-amount");
$amountEl.val(ev.currentTarget.dataset.amount);
$amountEl.trigger("change");
},
_is_all_input_valid() {
if($("#sendAsGiftCheckbox:checked").length > 0) {
var is_valid = true;
$("#gift-details input").each(function() {
if(!$(this).val()){
$(this).addClass("is-invalid");
$(this).removeClass("is-valid");
is_valid = false
} else{
$(this).removeClass("is-invalid");
$(this).addClass("is-valid");
}
});
if (!is_valid) {
return false
}
}
else {
var is_valid = true;
$(".ProhectDetailsSubBox input").each(function() {
if(!$(this).val() || $(this).val() == 0){
$(this).addClass("is-invalid");
$(this).removeClass("is-valid");
is_valid = false
} else{
$(this).removeClass("is-invalid");
$(this).addClass("is-valid");
}
});
if (!is_valid) {
return false
}
}
return true
}
});
})

View File

@ -1,55 +0,0 @@
@-moz-document url-prefix() {
.wpwl-container{
display: block !important;
}
}
@supports (-moz-appearance:none) {
.wpwl-container{
display: block !important;
}
}
@media (min-width: 480px) {
/* this rule applies only to devices with a minimum screen width of 480px */
.wpwl-button {
width: 50%;
}
}
.input {
height: 44px;
width: 100%;
}
.wpwl-button {
height: 44px;
width: 100%;
}
.wpwl-form {
background-color:#196956;
margin:0px;
max-width: 100%;
}
.wpwl-button-pay {
background: #196956;
color: #fff
}
.wpwl-button-pay:focus,.wpwl-button-pay:hover {
background: #196956!important;
color: #fff!important;
outline: none!important
}
.wpwl-label {
color:white;
}
.apple-pay-button-container {
width: 100%;
height: 100%;
border: none;
overflow: hidden;
margin-bottom: 10px;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -3,19 +3,9 @@
<template id="assets_frontend" name="Frontend Assets" inherit_id="web.assets_frontend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/p_donation_theme/static/src/scss/hyperpay_quick_donation.scss"/>
<link rel="stylesheet" type="text/scss" href="/p_donation_theme/static/src/scss/theme.scss"/>
<script type="text/javascript" src="/p_donation_theme/static/src/js/checkout.js"/>
<script type="text/javascript" src="/p_donation_theme/static/src/js/hyperpay_quick_donation.js"/>
<script type="text/javascript" src="/p_donation_theme/static/src/js/product-gift-card.js"/>
<script type="text/javascript" src="/p_donation_theme/static/src/js/website_sale_tracking.js"/>
</xpath>
</template>
<template id="_assets_primary_variables" inherit_id="web._assets_primary_variables">
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/p_donation_theme/static/src/scss/primary_variables.scss"/>
</xpath>
</template>
</data>
</odoo>