Shop module for AsgardCMS
config/app.php
'aliases' => [
// ...
'Image' => Intervention\Image\Facades\Image::class,
// ...
],
'providers' => [
// ...
Intervention\Image\ImageServiceProvider::class,
Spatie\Sitemap\SitemapServiceProvider::class,
Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class
// ...
]
./config/asgard/shop/core.php
(see ./Modules/Shop/Config/core.example
for format)davidkrenekcz/dynamicpages
- it is recommended you read documentation at https://packagist.org/packages/davidkrenekcz/dynamicpages
customer data dict
settings attribute.\Modules\Shop\Http\frontendRoutes.php
, \Modules\Shop\Http\Controllers\Frontend\ProductsController.php
and \Modules\Shop\Resources\views\frontend\product(s).blade.php
@include("shop::frontend.partials.cart-ajax", [ "omit" => [ ] ])
to bottom of your page (after jQuery is loaded)omit
parameteromit
values are
cart-add
, cart-update
, cart-remove
, cart-destroy
cart
(shortcut for all cart methods)order-customer-data
, order-delivery-data
, order-submit
order
(shortcut for all order methods)data-add-to-cart-id={{ $product->id }}
attribute to your link and the controller will take care of the restdata-remove-from-cart-id="{{ $item->rowId }}"
attribute to the delete link (where $item
is cart row instance)data-previous-value="{{ $item->qty }}"
and data-change-quantity-id="{{ $item->rowId }}"
attributes to your input (where $item
is cart row instance)data-row-id="{{ $item->rowId }}"
attribute is needed on update input's and remove button's closest <tr>
in order to update DOM successfully after the changedata-destroy-cart
attribute to your link and all is donedata-order-customer-field-name
or data-order-delivery-field-name
attribute with your desired field name name to each inputdata-order-rule
attribute to thememail
, phone
, number
, filled
, bool
or your custom regexhas-error
class is added to input's parent<option value="" data-filter-values="">Select shipping method</option>
data-order-delivery-field-name
attribute to your selects, with "country"
value for your contry select, "shipping"
value for your shipping method select and "payment"
value for your payment method selectdata-filter-values
to your country and shipping select, with supported shipping/payment methods' IDs separated by coma
data-filter-values="{{ implode(",", $country->shippingMethodsIds) }}"
or data-filter-values="{{ implode(",", $shipping->paymentsIds) }}"
value
same as the option's IDdata-submit-order-customer-data
or data-submit-order-delivery-data
to your button - the controller will validate and submit the form on clickdata-submit-order
attribute to your button - that's it!window.shop.on.{request name}.{event name}
objectrequest
for all requestsaddRequest
, updateRequest
, removeRequest
, destroyRequest
for cart requestscustomerDataRequest
, deliveryDataRequest
, submitOrderRequest
for order requestsstart
, end
, done
and fail
events, request
, customerDataRequest
and deliveryDataRequest
also support validationDone
and validationFail
eventsshop::frontend.partials.cart-ajax.blade.php
for more detailswindow.shop.alert(string, type)
function with your ownwindow.shop.loadinElement
attribute with your custom jQuery objectdata-cart-insert="items"
and data-cart-insert="price"
at the elements you want to insert quantity/price to and the controller will replace their content automatically each time cart content is changes{{ price($number) }}
or JavaScript function window.shop.price(number)
- decimal places, delimiters and currency can be set in module's settings, see Settings part of READMEwindow.shop.filterSelectValues(sourceSelect, targetSelect, sourceKeyAttribute?, targetKeyAttribute?, delimiter?)
\Modules\Shop\Resources\views\frontend\partials\cart-ajax.blade.php:151
\Modules\Shop\Http\frontendRoutes.php
, \Modules\Shop\Http\Controllers\Frontend\CartController.php
and \Modules\Shop\Resources\views\frontend
where fully functional shop prototype is readyModules\Shop\Facades\Cart
or AJAX API.shop-api/cart/(action)
where (action)
is insert
, update
, remove
or destroy
Modules\Shop\Facades\Cart
to manipulate cart contentModules\Shop\Facades\Cart.php
Modules\Shop\Facades\Order
and corresponding AJAX API is ready to help you with ordersstoreUserData
and storeDeliveryData
methods or api.shop.order.store user data
, api.shop.order.store delivery data
and api.shop.order.store order data
API routes.getStoredUserData
and getStoredDeliveryData
methodssubmitOrder
method or api.shop.order.submit
API route