From 461916a334c1c3daef60de5e0e319b9a610195b7 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 20 Nov 2017 16:44:28 +0200 Subject: [PATCH] Working on shipping address --- .../PaymentDrivers/BasePaymentDriver.php | 41 +++++++++---------- .../views/accounts/account_gateway.blade.php | 14 +++---- .../views/payments/credit_card.blade.php | 14 ++++--- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php index ae1eecf582..4e9e16dce6 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -407,32 +407,29 @@ class BasePaymentDriver } // update the address info - if ($this->accountGateway->update_address) { - $client = $this->client(); - if ($this->accountGateway->show_address) { - $client->address1 = trim($this->input['address1']); - $client->address2 = trim($this->input['address2']); - $client->city = trim($this->input['city']); - $client->state = trim($this->input['state']); - $client->postal_code = trim($this->input['postal_code']); - $client->country_id = trim($this->input['country_id']); - } - if ($this->accountGateway->show_shipping_address) { - $client->shipping_address1 = trim($this->input['shipping_address1']); - $client->shipping_address2 = trim($this->input['shipping_address2']); - $client->shipping_city = trim($this->input['shipping_city']); - $client->shipping_state = trim($this->input['shipping_state']); - $client->shipping_postal_code = trim($this->input['shipping_postal_code']); - $client->shipping_country_id = trim($this->input['shipping_country_id']); - } + $client = $this->client(); + + if ($this->accountGateway->show_address && $this->accountGateway->update_address) { + $client->address1 = trim($this->input['address1']); + $client->address2 = trim($this->input['address2']); + $client->city = trim($this->input['city']); + $client->state = trim($this->input['state']); + $client->postal_code = trim($this->input['postal_code']); + $client->country_id = trim($this->input['country_id']); } - if (! $this->accountGateway->show_address || ! $this->accountGateway->update_address) { - return; + if ($this->accountGateway->show_shipping_address) { + $client->shipping_address1 = trim($this->input['shipping_address1']); + $client->shipping_address2 = trim($this->input['shipping_address2']); + $client->shipping_city = trim($this->input['shipping_city']); + $client->shipping_state = trim($this->input['shipping_state']); + $client->shipping_postal_code = trim($this->input['shipping_postal_code']); + $client->shipping_country_id = trim($this->input['shipping_country_id']); } - - $client->save(); + if ($client->isDirty()) { + $client->save(); + } } protected function paymentDetails($paymentMethod = false) diff --git a/resources/views/accounts/account_gateway.blade.php b/resources/views/accounts/account_gateway.blade.php index 6b6150027a..2d1b570c84 100644 --- a/resources/views/accounts/account_gateway.blade.php +++ b/resources/views/accounts/account_gateway.blade.php @@ -158,15 +158,15 @@ ->addGroupClass('gateway-option') ->value(1) !!} - {!! Former::checkbox('show_shipping_address') - ->label(trans('texts.shipping_address')) - ->text(trans('texts.show_shipping_address_help')) + {!! Former::checkbox('update_address') + ->label(' ') + ->text(trans('texts.update_address_help')) ->addGroupClass('gateway-option') ->value(1) !!} - {!! Former::checkbox('update_address') - ->label(' ') - ->text(trans('texts.update_address_help')) + {!! Former::checkbox('show_shipping_address') + ->label(trans('texts.shipping_address')) + ->text(trans('texts.show_shipping_address_help')) ->addGroupClass('gateway-option') ->value(1) !!} @@ -303,7 +303,7 @@ } function enableUpdateAddress(event) { - var disabled = ! $('#show_address').is(':checked') && ! $('#show_shipping_address').is(':checked'); + var disabled = ! $('#show_address').is(':checked'); $('#update_address').prop('disabled', disabled); $('label[for=update_address]').css('color', disabled ? '#888' : '#000'); } diff --git a/resources/views/payments/credit_card.blade.php b/resources/views/payments/credit_card.blade.php index e73e716f44..442f0c4f83 100644 --- a/resources/views/payments/credit_card.blade.php +++ b/resources/views/payments/credit_card.blade.php @@ -236,12 +236,14 @@ @if (!empty($accountGateway->show_shipping_address))

{{ trans('texts.shipping_address') }}    - - - + @if ($accountGateway->show_address) + + + + @endif