From a1fd00908b17c9e4c5611573ebcf2a5d167483e7 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:59:32 -0300 Subject: [PATCH] de almacoop: soportar instrucciones especiales --- .../cart_payment_methods_controller.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/_packs/controllers/cart_payment_methods_controller.js b/_packs/controllers/cart_payment_methods_controller.js index 81d2e05..788012a 100644 --- a/_packs/controllers/cart_payment_methods_controller.js +++ b/_packs/controllers/cart_payment_methods_controller.js @@ -4,7 +4,7 @@ import { CartBaseController } from './cart_base_controller' * Retrieves payment methods and redirect to external checkouts */ export default class extends CartBaseController { - static targets = [ 'form', 'submit' ] + static targets = [ 'form', 'submit', 'specialInstructions' ] async connect () { const orderToken = this.token @@ -42,17 +42,21 @@ export default class extends CartBaseController { const payment_method_id = this.formTarget.elements.payment_method_id.value const orderToken = this.token + const special_instructions = this.specialInstructionsTarget.value.trim() // XXX: Currently SpreeClient expects us to send payment source // attributes as if it were a credit card. let response = await this.spree.checkout.orderUpdate({ orderToken }, { - order: { payments_attributes: [{ payment_method_id }] }, - payment_source: { - [payment_method_id]: { - name: 'Pepitx', - month: 12, - year: 2020 + order: { + special_instructions, + payments_attributes: [{ payment_method_id }] }, + payment_source: { + [payment_method_id]: { + name: 'Pepitx', + month: 12, + year: 2020 + } } } })