From b7777cd3b6ef20253e26841f965cb79ee3061f13 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Sun, 11 Feb 2024 16:51:38 +0000 Subject: [PATCH] Simple Commerce v6 (#188) * Widgets * Handle should be value. * Update default product blueprints Related: https://github.com/duncanmcclean/simple-commerce/pull/986 * New namespace * Update package namespace --- app/Tags/JsonRegions.php | 2 +- config/simple-commerce.php | 20 +-- config/statamic/cp.php | 159 ++++++++++++++++++ .../collections/products/product.yaml | 45 ++++- .../products/product_with_variants.yaml | 43 ++++- resources/views/checkout/payment.antlers.html | 2 +- starter-kit.yaml | 3 +- 7 files changed, 247 insertions(+), 27 deletions(-) create mode 100644 config/statamic/cp.php diff --git a/app/Tags/JsonRegions.php b/app/Tags/JsonRegions.php index b10e6e9..963ea55 100644 --- a/app/Tags/JsonRegions.php +++ b/app/Tags/JsonRegions.php @@ -2,7 +2,7 @@ namespace App\Tags; -use DoubleThreeDigital\SimpleCommerce\Regions; +use DuncanMcClean\SimpleCommerce\Regions; use Statamic\Tags\Tags; class JsonRegions extends Tags diff --git a/config/simple-commerce.php b/config/simple-commerce.php index 3d66bfe..9b15f26 100644 --- a/config/simple-commerce.php +++ b/config/simple-commerce.php @@ -20,7 +20,7 @@ 'shipping' => [ 'methods' => [ - \DoubleThreeDigital\SimpleCommerce\Shipping\FreeShipping::class => [], + \DuncanMcClean\SimpleCommerce\Shipping\FreeShipping::class => [], ], ], ], @@ -39,11 +39,11 @@ */ 'gateways' => [ - \DoubleThreeDigital\SimpleCommerce\Gateways\Builtin\DummyGateway::class => [ + \DuncanMcClean\SimpleCommerce\Gateways\Builtin\DummyGateway::class => [ 'display' => 'Card', ], - // \DoubleThreeDigital\SimpleCommerce\Gateways\Builtin\StripeGateway::class => [ + // \DuncanMcClean\SimpleCommerce\Gateways\Builtin\StripeGateway::class => [ // 'key' => env('STRIPE_KEY'), // 'secret' => env('STRIPE_SECRET'), // ], @@ -64,17 +64,17 @@ 'notifications' => [ 'order_paid' => [ - // \DoubleThreeDigital\SimpleCommerce\Notifications\CustomerOrderPaid::class => [ + // \DuncanMcClean\SimpleCommerce\Notifications\CustomerOrderPaid::class => [ // 'to' => 'customer', // ], - // \DoubleThreeDigital\SimpleCommerce\Notifications\BackOfficeOrderPaid::class => [ + // \DuncanMcClean\SimpleCommerce\Notifications\BackOfficeOrderPaid::class => [ // 'to' => 'duncan@example.com', // ], ], 'order_shipped' => [ - // \DoubleThreeDigital\SimpleCommerce\Notifications\CustomerOrderShipped::class => [ + // \DuncanMcClean\SimpleCommerce\Notifications\CustomerOrderShipped::class => [ // 'to' => 'customer', // ], ], @@ -117,7 +117,7 @@ | */ - 'tax_engine' => \DoubleThreeDigital\SimpleCommerce\Tax\BasicTaxEngine::class, + 'tax_engine' => \DuncanMcClean\SimpleCommerce\Tax\BasicTaxEngine::class, 'tax_engine_config' => [ // Basic Engine @@ -156,17 +156,17 @@ 'content' => [ 'customers' => [ - 'repository' => \DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository::class, + 'repository' => \DuncanMcClean\SimpleCommerce\Customers\EntryCustomerRepository::class, 'collection' => 'customers', ], 'orders' => [ - 'repository' => \DoubleThreeDigital\SimpleCommerce\Orders\EntryOrderRepository::class, + 'repository' => \DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository::class, 'collection' => 'orders', ], 'products' => [ - 'repository' => \DoubleThreeDigital\SimpleCommerce\Products\EntryProductRepository::class, + 'repository' => \DuncanMcClean\SimpleCommerce\Products\EntryProductRepository::class, 'collection' => 'products', ], ], diff --git a/config/statamic/cp.php b/config/statamic/cp.php new file mode 100644 index 0000000..1a4b266 --- /dev/null +++ b/config/statamic/cp.php @@ -0,0 +1,159 @@ + env('CP_ENABLED', true), + + 'route' => env('CP_ROUTE', 'cp'), + + /* + |-------------------------------------------------------------------------- + | Start Page + |-------------------------------------------------------------------------- + | + | When a user logs into the Control Panel, they will be taken here. + | For example: "dashboard", "collections/pages", etc. + | + */ + + 'start_page' => 'dashboard', + + /* + |-------------------------------------------------------------------------- + | Dashboard Widgets + |-------------------------------------------------------------------------- + | + | Here you may define any number of dashboard widgets. You're free to + | use the same widget multiple times in different configurations. + | + */ + + 'widgets' => [ + [ + 'type' => 'orders_chart', + 'width' => 100, + ], + [ + 'type' => 'recent_orders', + 'limit' => 5, + 'width' => 50, + ], + [ + 'type' => 'top_customers', + 'limit' => 5, + 'width' => 50, + ], + [ + 'type' => 'low_stock_products', + 'limit' => 5, + 'width' => 50, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Date Format + |-------------------------------------------------------------------------- + | + | When a date is encountered throughout the Control Panel, it will be + | rendered in the following format unless overridden in specific + | fields, and so on. Any PHP date variables are permitted. + | + | This takes precedence over the date_format in system.php. + | + | https://www.php.net/manual/en/function.date.php + | + */ + + 'date_format' => 'Y-m-d', + + /* + |-------------------------------------------------------------------------- + | Pagination + |-------------------------------------------------------------------------- + | + | Here you may define the default pagination size as well as the options + | the user can select on any paginated listing in the Control Panel. + | + */ + + 'pagination_size' => 50, + + 'pagination_size_options' => [10, 25, 50, 100, 500], + + /* + |-------------------------------------------------------------------------- + | Links to Documentation + |-------------------------------------------------------------------------- + | + | Show contextual links to documentation throughout the Control Panel. + | + */ + + 'link_to_docs' => env('STATAMIC_LINK_TO_DOCS', true), + + /* + |-------------------------------------------------------------------------- + | Support Link + |-------------------------------------------------------------------------- + | + | Set the location of the support link in the "Useful Links" header + | dropdown. Use 'false' to remove it entirely. + | + */ + + 'support_url' => env('STATAMIC_SUPPORT_URL', 'https://statamic.com/support'), + + /* + |-------------------------------------------------------------------------- + | Theme + |-------------------------------------------------------------------------- + | + | Optionally spice up the login and other outside-the-control-panel + | screens. You may choose between "rad" or "business" themes. + | + */ + + 'theme' => env('STATAMIC_THEME', 'rad'), + + /* + |-------------------------------------------------------------------------- + | White Labeling + |-------------------------------------------------------------------------- + | + | When in Pro Mode you may replace the Statamic name, logo, favicon, + | and add your own CSS to the control panel to match your + | company or client's brand. + | + */ + + 'custom_cms_name' => env('STATAMIC_CUSTOM_CMS_NAME', 'Statamic'), + + 'custom_logo_url' => env('STATAMIC_CUSTOM_LOGO_URL', null), + + 'custom_favicon_url' => env('STATAMIC_CUSTOM_FAVICON_URL', null), + + 'custom_css_url' => env('STATAMIC_CUSTOM_CSS_URL', null), + + /* + |-------------------------------------------------------------------------- + | Thumbnails + |-------------------------------------------------------------------------- + | + | Here you may define additional CP asset thumbnail presets. + | + */ + + 'thumbnail_presets' => [ + // 'medium' => 800, + ], +]; diff --git a/resources/blueprints/collections/products/product.yaml b/resources/blueprints/collections/products/product.yaml index 3877249..43fa984 100644 --- a/resources/blueprints/collections/products/product.yaml +++ b/resources/blueprints/collections/products/product.yaml @@ -80,11 +80,42 @@ sections: always_save: false sidebar: display: Sidebar - fields: + sections: - - handle: slug - field: - type: slug - localizable: true - validate: - - required + fields: + - + handle: product_type + field: + type: button_group + display: 'Product Type' + options: + physical: Physical + digital: Digital + default: physical + - + handle: slug + field: + type: slug + localizable: true + validate: + - required + - + display: 'Digital Product' + fields: + - + handle: downloadable_asset + field: + type: assets + mode: grid + display: 'Downloadable Asset' + container: assets + if: + root.product_type: 'equals digital' + - + handle: download_limit + field: + type: integer + display: 'Download Limit' + instructions: "If you'd like to limit the amount if times this product can be downloaded, set it here. Keep it blank if you'd like it to be unlimited." + if: + root.product_type: 'equals digital' diff --git a/resources/blueprints/collections/products/product_with_variants.yaml b/resources/blueprints/collections/products/product_with_variants.yaml index c147a12..40314cc 100644 --- a/resources/blueprints/collections/products/product_with_variants.yaml +++ b/resources/blueprints/collections/products/product_with_variants.yaml @@ -17,6 +17,24 @@ sections: type: product_variants icon: product_variants listable: hidden + option_fields: + - + handle: downloadable_asset + field: + type: assets + mode: grid + display: 'Downloadable Asset' + container: assets + if: + root.product_type: 'equals digital' + - + handle: download_limit + field: + type: integer + display: 'Download Limit' + instructions: "If you'd like to limit the amount if times this product can be downloaded, set it here. Keep it blank if you'd like it to be unlimited." + if: + root.product_type: 'equals digital' - handle: photos field: @@ -70,11 +88,22 @@ sections: always_save: false sidebar: display: Sidebar - fields: + sections: - - handle: slug - field: - type: slug - localizable: true - validate: - - required + fields: + - + handle: product_type + field: + type: button_group + display: 'Product Type' + options: + physical: Physical + digital: Digital + default: physical + - + handle: slug + field: + type: slug + localizable: true + validate: + - required diff --git a/resources/views/checkout/payment.antlers.html b/resources/views/checkout/payment.antlers.html index 7c77cea..9d85658 100644 --- a/resources/views/checkout/payment.antlers.html +++ b/resources/views/checkout/payment.antlers.html @@ -26,7 +26,7 @@

{{ partial:components/forms/select_field width="100" handle="gateway" display="Payment Method" x-model="gateway" required="true" }} {{ sc:gateways }} - + {{ /sc:gateways }} {{ /partial:components/forms/select_field }}
diff --git a/starter-kit.yaml b/starter-kit.yaml index 39713a4..e83da71 100644 --- a/starter-kit.yaml +++ b/starter-kit.yaml @@ -1,5 +1,6 @@ export_paths: - app/Tags/JsonRegions.php + - config/statamic/cp.php - config/statamic/editions.php - config/statamic/sites.php - config/simple-commerce.php @@ -28,4 +29,4 @@ export_paths: - tailwind.config.typography.js - vite.config.js dependencies: - doublethreedigital/simple-commerce: "^5.0" + duncanmcclean/simple-commerce: "^6.0"