Working on shipping address

This commit is contained in:
Hillel Coren 2017-11-20 16:44:28 +02:00
parent ebedbf8809
commit 461916a334
3 changed files with 34 additions and 35 deletions

View File

@ -407,9 +407,9 @@ class BasePaymentDriver
} }
// update the address info // update the address info
if ($this->accountGateway->update_address) {
$client = $this->client(); $client = $this->client();
if ($this->accountGateway->show_address) {
if ($this->accountGateway->show_address && $this->accountGateway->update_address) {
$client->address1 = trim($this->input['address1']); $client->address1 = trim($this->input['address1']);
$client->address2 = trim($this->input['address2']); $client->address2 = trim($this->input['address2']);
$client->city = trim($this->input['city']); $client->city = trim($this->input['city']);
@ -417,6 +417,7 @@ class BasePaymentDriver
$client->postal_code = trim($this->input['postal_code']); $client->postal_code = trim($this->input['postal_code']);
$client->country_id = trim($this->input['country_id']); $client->country_id = trim($this->input['country_id']);
} }
if ($this->accountGateway->show_shipping_address) { if ($this->accountGateway->show_shipping_address) {
$client->shipping_address1 = trim($this->input['shipping_address1']); $client->shipping_address1 = trim($this->input['shipping_address1']);
$client->shipping_address2 = trim($this->input['shipping_address2']); $client->shipping_address2 = trim($this->input['shipping_address2']);
@ -425,15 +426,11 @@ class BasePaymentDriver
$client->shipping_postal_code = trim($this->input['shipping_postal_code']); $client->shipping_postal_code = trim($this->input['shipping_postal_code']);
$client->shipping_country_id = trim($this->input['shipping_country_id']); $client->shipping_country_id = trim($this->input['shipping_country_id']);
} }
}
if (! $this->accountGateway->show_address || ! $this->accountGateway->update_address) {
return;
}
if ($client->isDirty()) {
$client->save(); $client->save();
} }
}
protected function paymentDetails($paymentMethod = false) protected function paymentDetails($paymentMethod = false)
{ {

View File

@ -158,18 +158,18 @@
->addGroupClass('gateway-option') ->addGroupClass('gateway-option')
->value(1) !!} ->value(1) !!}
{!! Former::checkbox('show_shipping_address')
->label(trans('texts.shipping_address'))
->text(trans('texts.show_shipping_address_help'))
->addGroupClass('gateway-option')
->value(1) !!}
{!! Former::checkbox('update_address') {!! Former::checkbox('update_address')
->label(' ') ->label(' ')
->text(trans('texts.update_address_help')) ->text(trans('texts.update_address_help'))
->addGroupClass('gateway-option') ->addGroupClass('gateway-option')
->value(1) !!} ->value(1) !!}
{!! Former::checkbox('show_shipping_address')
->label(trans('texts.shipping_address'))
->text(trans('texts.show_shipping_address_help'))
->addGroupClass('gateway-option')
->value(1) !!}
{!! Former::checkboxes('creditCardTypes[]') {!! Former::checkboxes('creditCardTypes[]')
->label('accepted_card_logos') ->label('accepted_card_logos')
->checkboxes($creditCardTypes) ->checkboxes($creditCardTypes)
@ -303,7 +303,7 @@
} }
function enableUpdateAddress(event) { 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); $('#update_address').prop('disabled', disabled);
$('label[for=update_address]').css('color', disabled ? '#888' : '#000'); $('label[for=update_address]').css('color', disabled ? '#888' : '#000');
} }

View File

@ -236,12 +236,14 @@
@if (!empty($accountGateway->show_shipping_address)) @if (!empty($accountGateway->show_shipping_address))
<h3>{{ trans('texts.shipping_address') }} &nbsp;&nbsp; <h3>{{ trans('texts.shipping_address') }} &nbsp;&nbsp;
@if ($accountGateway->show_address)
<span> <span>
<label for="shipToBillingAddress" style="font-weight:normal"> <label for="shipToBillingAddress" style="font-weight:normal">
<input id="shipToBillingAddress" type="checkbox"/> <input id="shipToBillingAddress" type="checkbox"/>
{{ trans('texts.ship_to_billing_address') }} {{ trans('texts.ship_to_billing_address') }}
</label> </label>
</span> </span>
@endif
</h3> </h3>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">