Price added to downloadable product links

This commit is contained in:
jitendra 2019-09-11 13:46:33 +05:30
parent 6384b84746
commit 484fb56e54
5 changed files with 32 additions and 7 deletions

View File

@ -45,6 +45,7 @@
<thead>
<tr>
<th>{{ __('admin::app.catalog.products.name') }}</th>
<th>{{ __('admin::app.catalog.products.price') }}</th>
<th>{{ __('admin::app.catalog.products.file') }}</th>
<th>{{ __('admin::app.catalog.products.sample') }}</th>
<th>{{ __('admin::app.catalog.products.downloads') }}</th>
@ -84,6 +85,14 @@
</div>
</td>
<td>
<div class="control-group" :class="[errors.has(linkInputName + '[price]') ? 'has-error' : '']">
<input type="text" v-validate="'min_value:0'" v-model="link.price" :name="[linkInputName + '[price]']" class="control" data-vv-as="&quot;{{ __('admin::app.catalog.products.price') }}&quot;"/>
<span class="control-error" v-if="errors.has(linkInputName + '[price]')">@{{ errors.first(linkInputName + '[price]') }}</span>
</div>
</td>
<td>
<div class="control-group" style="margin-bottom: 10px;">
<select v-model="link.type" :name="[linkInputName + '[type]']" class="control">
@ -115,7 +124,7 @@
<div class="control-group" :class="[errors.has(linkInputName + '[url]') ? 'has-error' : '']" v-if="link.type == 'url'">
<input type="text" v-validate="'required'" v-model="link.url" :name="[linkInputName + '[url]']" class="control" data-vv-as="&quot;{{ __('admin::app.catalog.products.url') }}&quot;"/>
<span class="control-error" v-if="errors.has(linkInputName + '[url]')">@{{ errors.first(linkInputName + '[downloads]') }}</span>
<span class="control-error" v-if="errors.has(linkInputName + '[url]')">@{{ errors.first(linkInputName + '[url]') }}</span>
</div>
</td>

View File

@ -19,7 +19,7 @@ class CreateProductDownloadableLinksTable extends Migration
$table->string('file')->nullable();
$table->string('file_name')->nullable();
$table->string('type');
$table->decimal('price', 12, 4)->nullable();
$table->decimal('price', 12, 4)->default(0);
$table->string('sample_url')->nullable();
$table->string('sample_file')->nullable();
$table->string('sample_file_name')->nullable();

View File

@ -10,7 +10,7 @@ class ProductDownloadableLink extends TranslatableModel implements ProductDownlo
{
public $translatedAttributes = ['title'];
protected $fillable = ['title', 'url', 'file', 'file_name', 'type', 'sample_url', 'sample_file', 'sample_file_name', 'sample_type', 'sort_order', 'product_id', 'downloads'];
protected $fillable = ['title', 'price', 'url', 'file', 'file_name', 'type', 'sample_url', 'sample_file', 'sample_file_name', 'sample_type', 'sort_order', 'product_id', 'downloads'];
protected $with = ['translations'];

View File

@ -162,7 +162,19 @@ class Downloadable extends AbstractType
if(! isset($data['links']) || ! count($data['links']))
return trans('shop::app.checkout.cart.integrity.missing_links');
return parent::prepareForCart($data);
$products = parent::prepareForCart($data);
foreach ($this->product->downloadable_links as $link) {
if (! in_array($link->id, $data['links']))
continue;
$products[0]['price'] += core()->convertPrice($link->price);
$products[0]['base_price'] += $link->price;
$products[0]['total'] += (core()->convertPrice($link->price) * $products[0]['quantity']);
$products[0]['base_total'] += ($link->price * $products[0]['quantity']);
}
return $products;
}
/**

View File

@ -10,7 +10,9 @@
<ul>
@foreach ($product->downloadable_samples as $sample)
<li>
<a href="{{ route('shop.downloadable.download_sample', ['type' => 'sample', 'id' => $sample->id]) }}" target="_blank">{{ $sample->title }}</a>
<a href="{{ route('shop.downloadable.download_sample', ['type' => 'sample', 'id' => $sample->id]) }}" target="_blank">
{{ $sample->title }}
</a>
</li>
@endforeach
</ul>
@ -27,11 +29,13 @@
<span class="checkbox">
<input type="checkbox" name="links[]" v-validate="'required'" value="{{ $link->id }}" id="{{ $link->id }}" data-vv-as="&quot;{{ __('shop::app.products.links') }}&quot;"/>
<label class="checkbox-view" for="{{ $link->id }}"></label>
{{ $link->title }}
{{ $link->title . ' + ' . core()->currency($link->price) }}
</span>
@if ($link->sample_file || $link->sample_url)
<a href="{{ route('shop.downloadable.download_sample', ['type' => 'link', 'id' => $link->id]) }}" target="_blank">{{ __('shop::app.products.sample') }}</a>
<a href="{{ route('shop.downloadable.download_sample', ['type' => 'link', 'id' => $link->id]) }}" target="_blank">
{{ __('shop::app.products.sample') }}
</a>
@endif
</li>
@endforeach