[IMP] p_donation_theme: add dynamic amount
This commit is contained in:
parent
76dc2a7790
commit
93d2a63762
|
|
@ -151,8 +151,8 @@ class PaymentPortalExtraFields(PaymentPortal):
|
|||
success = False
|
||||
order = request.website.sale_get_order(force_create=True)
|
||||
product_id = kw.pop('product_id')
|
||||
acquire_id = kw.pop('acquire_id')
|
||||
mobile = kw.pop('mobile')
|
||||
acquire_id = kw.pop('acquire_id', request.env.ref('payment_applepay.payment_acquirer_applepay').id)
|
||||
mobile = kw.pop('mobile', '')
|
||||
if order:
|
||||
if product_id:
|
||||
product_id = request.env['product.product'].sudo().browse(int(product_id))
|
||||
|
|
|
|||
|
|
@ -30,22 +30,23 @@ odoo.define('p_donation_theme.product-gift-card', function (require) {
|
|||
|
||||
_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');
|
||||
if (amounts.length > 0) {
|
||||
amounts.get(0).click();
|
||||
}
|
||||
const $parent = this.$el.find('.js_product');
|
||||
const product_id = this._getProductId($parent);
|
||||
if (product_id) {
|
||||
const amount = this._get_donation_amount();
|
||||
if (product_id && amount) {
|
||||
const data = await this._rpc({
|
||||
route: '/quickpay/hyperpay/payment/create',
|
||||
params: {
|
||||
'acquire_id': 20,
|
||||
'product_id': product_id,
|
||||
'currency_id': 148,
|
||||
'mobile': '',
|
||||
'amount': 100,
|
||||
'amount': amount,
|
||||
'is_donation_detail_page': true
|
||||
}
|
||||
});
|
||||
|
|
@ -64,6 +65,17 @@ odoo.define('p_donation_theme.product-gift-card', function (require) {
|
|||
}
|
||||
},
|
||||
|
||||
_get_donation_amount(){
|
||||
let amount = ArabictoEnglishNumber(this.$el.find('input.donation-input-amt').val());
|
||||
if (!amount) {
|
||||
const $amountEl = this.$('#fixedqtyinput-1');
|
||||
let qty = parseFloat($amountEl.val(), 10);
|
||||
let price = parseFloat($amountEl.data('price'), 10);
|
||||
amount = qty * price;
|
||||
}
|
||||
return amount;
|
||||
},
|
||||
|
||||
_submitForm() {
|
||||
const params = this.rootProduct;
|
||||
const $product = $('#product_detail');
|
||||
|
|
|
|||
Loading…
Reference in New Issue