Added custom fields to buy now buttons

This commit is contained in:
Hillel Coren 2017-03-30 12:40:04 +03:00
parent 3f8aa3c686
commit f1486ca6eb
3 changed files with 43 additions and 0 deletions

View File

@ -330,6 +330,8 @@ class OnlinePaymentController extends BaseController
$data = [
'currency_id' => $account->currency_id,
'contact' => Input::all(),
'custom_value1' => Input::get('custom_client1'),
'custom_value2' => Input::get('custom_client2'),
];
$client = $clientRepo->save($data, $client);
}
@ -343,6 +345,8 @@ class OnlinePaymentController extends BaseController
'start_date' => Input::get('start_date', date('Y-m-d')),
'tax_rate1' => $account->default_tax_rate ? $account->default_tax_rate->rate : 0,
'tax_name1' => $account->default_tax_rate ? $account->default_tax_rate->name : '',
'custom_text_value1' => Input::get('custom_invoice1'),
'custom_text_value2' => Input::get('custom_invoice2'),
'invoice_items' => [[
'product_key' => $product->product_key,
'notes' => $product->notes,
@ -350,6 +354,8 @@ class OnlinePaymentController extends BaseController
'qty' => 1,
'tax_rate1' => $product->default_tax_rate ? $product->default_tax_rate->rate : 0,
'tax_name1' => $product->default_tax_rate ? $product->default_tax_rate->name : '',
'custom_value1' => Input::get('custom_product1') ?: $product->custom_value1,
'custom_value2' => Input::get('custom_product2') ?: $product->custom_value2,
]],
];
$invoice = $invoiceService->save($data);

View File

@ -149,4 +149,28 @@ class AccountPresenter extends Presenter
return $options;
}
public function customTextFields()
{
$fields = [
'custom_client_label1' => 'custom_client1',
'custom_client_label2' => 'custom_client2',
'custom_invoice_text_label1' => 'custom_invoice1',
'custom_invoice_text_label2' => 'custom_invoice2',
'custom_invoice_item_label1' => 'custom_product1',
'custom_invoice_item_label2' => 'custom_product2',
];
$data = [];
foreach ($fields as $key => $val) {
if ($this->$key) {
$data[$this->$key] = [
'value' => $val,
'name' => $val,
];
}
}
return $data;
}
}

View File

@ -240,6 +240,12 @@
->inlineHelp('buy_now_buttons_warning')
->addGroupClass('product-select') !!}
@if (count($account->present()->customTextFields))
{!! Former::inline_checkboxes('custom_fields')
->onchange('updateBuyNowButtons()')
->checkboxes($account->present()->customTextFields) !!}
@endif
{!! Former::inline_radios('landing_page')
->onchange('showPaymentTypes();updateBuyNowButtons();')
->radios([
@ -426,6 +432,13 @@ iframe.src = '{{ rtrim(SITE_URL ,'/') }}/view/'
var form = '<form action="' + link + '" method="post" target="_top">' + "\n";
@foreach (['custom_client1', 'custom_client2', 'custom_invoice1', 'custom_invoice2', 'custom_product1', 'custom_product2'] as $field)
if ($('input#{{ $field }}').is(':checked')) {
form += '<input type="text" name="{{ $field }}" placeholder="{{ trans("texts.{$field}") }}" required/>' + "\n";
link += '&{{ $field }}=';
}
@endforeach
if (redirectUrl) {
link += '&redirect_url=' + encodeURIComponent(redirectUrl);
form += '<input type="hidden" name="redirect_url" value="' + redirectUrl + '"/>' + "\n";