添加插件开发demo
This commit is contained in:
parent
0c47803a90
commit
588d3b0e90
|
|
@ -22,8 +22,23 @@ class Bootstrap
|
|||
|
||||
// $this->modifyHeader();
|
||||
// $this->modifyProductDetail();
|
||||
|
||||
// $this->modifyAdminProductEdit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 后台产品编辑页添加自定义字段
|
||||
*/
|
||||
private function modifyAdminProductEdit()
|
||||
{
|
||||
blade_hook('admin.product.edit.extra', function ($callback, $output, $data) {
|
||||
$view = view('LatestProducts::admin.product.edit_extra_field', $data)->render();
|
||||
return $output . $view;
|
||||
}, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在前台网页头部添加二级菜单链接
|
||||
*/
|
||||
|
|
@ -35,7 +50,7 @@ class Bootstrap
|
|||
"link" => plugin_route('latest_products'),
|
||||
];
|
||||
return $data;
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -61,7 +76,7 @@ class Bootstrap
|
|||
});
|
||||
|
||||
blade_hook('header.menu.icon', function ($callback, $output, $data) {
|
||||
$view = view('LatestProducts::header_icon')->render();
|
||||
$view = view('LatestProducts::shop.header_icon')->render();
|
||||
return $output . $view;
|
||||
});
|
||||
}
|
||||
|
|
@ -69,17 +84,23 @@ class Bootstrap
|
|||
|
||||
/**
|
||||
* 修改产品详情页
|
||||
* 1. 在产品名称上面添加 Hot 标签
|
||||
* 1. 品牌下面添加信息
|
||||
* 2. 立即购买后添加按钮
|
||||
*/
|
||||
private function modifyProductDetail()
|
||||
{
|
||||
blade_hook('product.detail.name', function ($callback, $output, $data) {
|
||||
$badge = '<span class="badge" style="background-color: #FF4D00; color: #ffffff; border-color: #FF4D00">Hot</span>';
|
||||
return $badge . $output;
|
||||
});
|
||||
|
||||
blade_hook('product.detail.brand', function ($callback, $output, $data) {
|
||||
return $output . '<div class="d-flex"><span class="title text-muted">Brand 2:</span>品牌 2</div>';
|
||||
});
|
||||
|
||||
blade_hook('product.detail.buy.after', function ($callback, $output, $data) {
|
||||
$view = view('LatestProducts::product_button')->render();
|
||||
$view = view('LatestProducts::shop.product_button')->render();
|
||||
return $output . $view;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ class MenusController extends Controller
|
|||
'products' => $products,
|
||||
'items' => ProductSimple::collection($products)->jsonSerialize(),
|
||||
];
|
||||
return view("LatestProducts::latest_products", $data);
|
||||
return view('LatestProducts::shop.latest_products', $data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<x-admin-form-input name="custom_field" :title="'自定义字段'" :value="old('custom_field', $product->custom_field ?? '')" />
|
||||
|
|
@ -76,10 +76,12 @@
|
|||
{{-- <x-admin-form-input name="video" title="视频" :value="old('video', $product->video ?? '')" /> --}}
|
||||
<x-admin-form-input name="position" :title="__('common.sort_order')" :value="old('position', $product->position ?? '0')" />
|
||||
|
||||
@hook('admin.product.edit.brand', true)
|
||||
<x-admin::form.row :title="__('admin/brand.index')">
|
||||
<input type="text" value="{{ $product->brand->name ?? '' }}" id="brand-autocomplete" class="form-control wp-400 " />
|
||||
<input type="hidden" name="brand_id" value="{{ old('brand_id', $product->brand_id ?? '') }}" />
|
||||
</x-admin::form.row>
|
||||
@endhook
|
||||
|
||||
<x-admin-form-select :title="__('admin/tax_class.index')" name="tax_class_id" :value="old('tax_class_id', $product->tax_class_id ?? '')" :options="$tax_classes" key="id" label="title" />
|
||||
<x-admin-form-switch name="active" :title="__('common.status')" :value="old('active', $product->active ?? 1)" />
|
||||
|
|
@ -98,6 +100,8 @@
|
|||
</div>
|
||||
</x-admin::form.row>
|
||||
|
||||
@hook('admin.product.edit.extra')
|
||||
|
||||
<div>
|
||||
<h5 class="border-bottom pb-3 mb-4">{{ __('admin/product.stocks') }}</h5>
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,9 @@
|
|||
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="peoduct-info">
|
||||
@hook('product.detail.name', true)
|
||||
<h1 class="mb-4 product-name">{{ $product['name'] }}</h1>
|
||||
@endhook
|
||||
<div class="price-wrap d-flex align-items-end">
|
||||
<div class="new-price fs-1 lh-1 fw-bold me-2">@{{ product.price_format }}</div>
|
||||
<div class="old-price text-muted text-decoration-line-through" v-if="product.price != product.origin_price && product.origin_price !== 0">
|
||||
|
|
|
|||
Loading…
Reference in New Issue