dynamic/silverstripe-product-wishlist
Composer 安装命令:
composer require dynamic/silverstripe-product-wishlist
包简介
adds a product wish list to your website
关键字:
README 文档
README
product-wishlist
Allows users to create and manage a wish list on a website.
Requirements
- silverstripe/recipe-cms ^4.0
- dynamic/viewable-dataobject ^2.0
- dynamic/silverstripe-additional-formfields ^2.0
- dynamic/silverstripe-manageable-dataobject ^2.0
Installation
composer require dynamic/silverstripe-product-wishlist
Example usage
This module was not hooked up with any particular module that adds products to allow flexibility. The examples here will use FoxyStripe.
ProductWishList Extension
A product relation must be added to Dynamic\Wishlist\Model\ProductWishList through a DataExtension.
Dynamic\Wishlist\Model\ProductWishList: extensions: - Foo\Bar\ORM\WishListExtension
<?php namespace Foo\Bar\ORM; use Dynamic\FoxyStripe\Page\ProductPage; use SilverStripe\ORM\DataExtension; class WishListExtension extends DataExtension { /** * @var array */ private static $many_many = [ 'Products' => ProductPage::class, ]; }
Product Relation
The Product must also have a reciprocal relation to wishlists.
Dynamic\FoxyStripe\Page\ProductPage: extensions: - Foo\Bar\ORM\ProductExtension
<?php namespace Foo\Bar\ORM; use Dynamic\Wishlist\Model\ProductWishList; class ProductExtension extends DataExtension { /** * @var array */ private static $belongs_many_many = [ 'WishLists' => ProductWishList::class, ]; }
WishList Form
The ProductControllerExtension should be applied to the controller that handles showing a product.
Dynamic\FoxyStripe\Page\ProductPageController: extensions: - Dynamic\Wishlist\Extensions\ProductControllerExtension
The form can be passed a product id to avoid using the current controller's page id. The form will not show if the user is not logged in.
AddToWishListForm and RemoveFromWishListForm
The only real difference between these forms are the actions the forms call and an extra class.
updateWishLists
An extension point for updating the wishlists visible in the dropdown field.
It is passed a DataList of the wishlists associated with the current user.
/** * @param SilverStripe\ORM\DataList $lists */ public function updateWishLists($lists) { // Stuff here }
updateFields
An extension point for updating the fields for the form.
It is passed a FieldList and an int.
/** * @param SilverStripe\Forms\FieldList $fields * @param int $productID */ public function updateFields($fields, $productID) { // Stuff here }
updateActions
An extension point for updating the actions for the form.
It is passed a FieldList and an int.
/** * @param SilverStripe\Forms\FieldList $actions * @param int $productID */ public function updateActions($actions, $productID) { // Stuff here }
WishList Form Handling
Handling the addToWishList and removeFromWishList actions is not included by default.
The example implementations should be on a controller, or an extension applied to a controller.
addToWishList Example
/** * @param $data * @param \SilverStripe\Forms\Form $form * @return \SilverStripe\Control\HTTPResponse * @throws \Exception */ public function addToWishList($data, Form $form) { /** @var ProductWishList|\Foo\Bar\Extension\WishListExtension $list */ $list = ProductWishList::get()->filter([ 'ID' => $data['List'], ])->first(); $list->Products()->add($data['ProductID']); return $this->owner->redirectBack(); }
removeFromWishList Example
/** * @param $data * @param \SilverStripe\Forms\Form $form * @return \SilverStripe\Control\HTTPResponse * @throws \Exception */ public function removeFromWishList($data, Form $form) { /** @var ProductWishList|\Foo\Bar\Extension\WishListExtension $list */ $list = ProductWishList::get()->filter([ 'ID' => $data['List'], ])->first(); $list->Products()->removeByID($data['ProductID']); return $this->owner->redirectBack(); }
Documentation
See the docs/en folder.
dynamic/silverstripe-product-wishlist 适用场景与选型建议
dynamic/silverstripe-product-wishlist 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dynamic/silverstripe-product-wishlist 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dynamic/silverstripe-product-wishlist 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dynamic/silverstripe-product-wishlist 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Analytics chooser extensions for site settings.
CitaNZ's SilverStripe picture object and field for SilverStripe 4
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Allows you to defined CMS form structure via config.yml
A module for adding a podcast or multiple podcasts to your SilverStripe site. With support for audio, video or other files.
统计信息
- 总下载量: 64
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2022-10-04