Mapbox API + SilverShop improvements

This commit is contained in:
Tony Air 2018-08-26 17:46:03 +07:00
parent 69c6209250
commit 179d8232d1
36 changed files with 862 additions and 322 deletions

109
.htaccess Normal file
View File

@ -0,0 +1,109 @@
Header set X-Content-Security-Policy "allow 'self'; media-src *; img-src *; script-src 'self' https://ajax.googleapis.com; style-src 'self';"
Header always append X-Frame-Options SAMEORIGIN
ServerSignature Off
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
# Deny access to IIS configuration
<Files web.config>
Order deny,allow
Deny from all
</Files>
# Deny access to YAML configuration files which might include sensitive information
<Files *.yml>
Order allow,deny
Deny from all
</Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/'
# Deny access to potentially sensitive files and folders
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule composer\.(json|lock) - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule .* framework/main.php?url=%1 [QSA]
</IfModule>
### SILVERSTRIPE END ###
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^\.git - [F,L,NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule \.sql$ - [F,L,NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule \.editorconfig - [F,L,NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule error_log - [F,L,NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule Envoy\.blade\.php - [F,L,NC]

View File

@ -21,9 +21,5 @@ SilverStripe\Forms\HTMLEditor\TinyMCEConfig:
editor_css:
- 'app/client/dist/css/editor.css'
SilverStripe\Assets\File:
allowed_extensions:
- svg
app_categories:
image:
- svg
SilverShop\Extension\ShopConfigExtension:
base_currency: USD

View File

@ -25,6 +25,8 @@ SilverStripe\CMS\Model\SiteTree:
- Dynamic\Elements\Elements\ElementTestimonials
- Site\Elements\TeamMembersElement
- Site\Elements\SliderElement
- Site\Elements\PromotionElement
- Site\Elements\StoreElement
DNADesign\ElementalList\Model\ElementList:
default_global_elements: false

View File

@ -14,3 +14,9 @@ SilverStripe\Blog\Model\BlogPost:
SilverStripe\Core\Injector\Injector:
SilverStripe\UserForms\Model\UserDefinedForm:
class: Site\Extensions\CMSMain_HiddenClass
SilverShop\Checkout\SinglePageCheckoutComponentConfig:
class: Site\Models\CheckoutNoDeliveryConfig
#SilverShop\Model\Address:
# extensions:
# - Site\Extensions\AddressExtension

View File

@ -0,0 +1,3 @@
BetterBrief\GoogleMapField:
default_options:
api_key: 'YOUR_API_KEY'

6
app/_config/payment.yml Normal file
View File

@ -0,0 +1,6 @@
---
Name: payment
---
SilverStripe\Omnipay\Model\Payment:
allowed_gateways:
- 'Manual'

View File

@ -3,4 +3,8 @@ Site\Templates\DeferedRequirements:
nofontawesome: false
version: false
static_domain: false
custom_requirements:
SilverShop\Page\AccountPageController:
- SilverShop.Page.CheckoutPageController.js
- SilverShop.Page.CheckoutPageController.css

View File

@ -5,162 +5,182 @@ import Events from "../_events";
import mapBoxGL from "mapbox-gl";
//import "./mapStorage";
import "../../scss/types/MapPage.scss";
import "../../scss/_components/_ui.map.scss";
const W = window;
const MapAPI = (($) => {
const STORAGE = W.localStorage;
const STORAGE = W.localStorage;
// Constants
const NAME = 'jsMapAPI';
const DATA_KEY = NAME;
const $BODY = $('body');
let Map;
let currentStyle;
// Constants
const NAME = 'jsMapAPI';
const DATA_KEY = NAME;
const $BODY = $('body');
let Map;
let currentStyle;
class MapAPI {
// Constructor
constructor(element) {
this._element = element;
const $element = $(this._element);
currentStyle = this.getStyle();
class MapAPI {
// Constructor
constructor(element) {
this._element = element;
const $element = $(this._element);
const geojson = $element.data('geojson');
const center = [
($element.data('lng') ? $element.data('lng') : $BODY.data('default-lng')),
($element.data('lat') ? $element.data('lat') : $BODY.data('default-lat')),
];
const popup = new mapboxgl.Popup({
closeOnClick: false,
className: 'popup'
});
currentStyle = this.getStyle();
mapBoxGL.accessToken = $element.data('key');
mapBoxGL.accessToken = 'pk.eyJ1IjoidG9ueS1haXIiLCJhIjoiY2l1OHoxZGp4MDAxZzJ0cHl0Y25jOWFpMCJ9.BC-YvTC2hUKhNbae4iAPCA';
Map = new mapBoxGL.Map({
'container': $element.find('.mapAPI-map')[0],
'center': center,
//hash: true,
'style': currentStyle,
//localIdeographFontFamily: $BODY.css('font-family'),
'zoom': ($element.data('map-zoom') ? $element.data('map-zoom') : 10),
'attributionControl': false
/*transformRequest: (url, resourceType)=> {
if(resourceType === 'Source' && url.startsWith('http://myHost')) {
return {
url: url.replace('http', 'https'),
headers: { 'my-custom-header': true},
credentials: 'include' // Include cookies for cross-origin requests
}
}
}*/
})
.addControl(new mapBoxGL.AttributionControl({
compact: true
}))
.addControl(new mapBoxGL.NavigationControl(), 'top-right')
.addControl(new mapBoxGL.GeolocateControl({
positionOptions: {
enableHighAccuracy: true,
},
trackUserLocation: true,
}), 'bottom-right')
.addControl(new mapboxgl.ScaleControl({
maxWidth: 80,
unit: 'metric'
}), 'top-left');
Map = new mapBoxGL.Map({
container: $element.find('.mapAPI-map')[0],
center: [$BODY.data('default-lng'), $BODY.data('default-lat')],
//hash: true,
style: currentStyle,
//localIdeographFontFamily: $BODY.css('font-family'),
zoom: $element.data('map-zoom'),
attributionControl: false
/*transformRequest: (url, resourceType)=> {
if(resourceType === 'Source' && url.startsWith('http://myHost')) {
return {
url: url.replace('http', 'https'),
headers: { 'my-custom-header': true},
credentials: 'include' // Include cookies for cross-origin requests
}
}
}*/
})
.addControl(new mapBoxGL.AttributionControl({
compact: true
}))
.addControl(new mapBoxGL.NavigationControl(), 'top-right')
.addControl(new mapBoxGL.GeolocateControl({
positionOptions: {
enableHighAccuracy: true,
},
trackUserLocation: true,
}),'bottom-right')
.addControl(new mapboxgl.ScaleControl({
maxWidth: 80,
unit: 'metric'
}),'top-left');
// event.target
Map.on('load', (e) => {
// add markers to map
geojson.features.forEach(function(marker) {
// create a DOM element for the marker
const $el = $('<div class="marker">' + marker.icon + '</div>');
// event.target
Map.on('load',(e) => {
console.log('Map is loaded');
/*Map.addSource('dem', {
"type": "raster-dem",
"url": "mapbox://mapbox.terrain-rgb"
});
Map.addLayer({
"id": "hillshading",
"source": "dem",
"type": "hillshade"
});*/
});
$el.on('click', function() {
console.log('Marker click');
const coordinates = marker.geometry.coordinates;
const content = marker.properties.content;
console.log(popup);
popup.setLngLat(coordinates)
.setHTML(content)
.addTo(Map);
});
/*Map.on('render',function(event){
console.log('map moved');
console.log(event);
});
// add marker to map
new mapboxgl.Marker($el[0])
.setLngLat(marker.geometry.coordinates)
.addTo(Map);
});
// event: MapDataEvent
Map.on('dataloading',() => {
console.log('Loading map data');
//console.log(event);
});
console.log('Map is loaded');
});
// event: MapDataEvent
Map.on('data',(event) => {
console.log('Map data updated');
//console.log(event);
});*/
/*Map.on('render',function(event){
console.log('map moved');
console.log(event);
});
// check time every 60 mins and change to night style
const api = this;
setInterval(() => {
const newStyle = api.getStyle();
if(newStyle !== currentStyle){
Map.setStyle(api.getStyle());
// event: MapDataEvent
Map.on('dataloading',() => {
console.log('Loading map data');
//console.log(event);
});
// event: MapDataEvent
Map.on('data',(event) => {
console.log('Map data updated');
//console.log(event);
});*/
// check time every 60 mins and change to night style
const api = this;
setInterval(() => {
const newStyle = api.getStyle();
if (newStyle !== currentStyle) {
Map.setStyle(api.getStyle());
}
}, 36000);
$element.addClass(`${NAME}-active`);
}
},36000);
// Public methods
getMap() {
return Map;
}
$element.addClass(`${NAME}-active`);
getStyle() {
return 'mapbox://styles/mapbox/streets-v9';
const hour = new Date().getHours();
if (hour < 6 || hour > 18) {
// night
//return 'mapbox://styles/mapbox/streets-v7';
return 'mapbox://styles/tony-air/cjeacwih92iu42rpd8tcmuyb2';
} else {
// day
return 'mapbox://styles/mapbox/streets-v9';
}
}
dispose() {
const $element = $(this._element);
$element.removeClass(`${NAME}-active`);
$.removeData(this._element, DATA_KEY);
this._element = null;
}
static _jQueryInterface() {
if (typeof W.localStorage !== 'undefined') {
return this.each(function() {
// attach functionality to element
const $element = $(this);
let data = $element.data(DATA_KEY);
if (!data) {
data = new MapAPI(this);
$element.data(DATA_KEY, data);
}
});
}
}
}
// Public methods
getMap() {
return Map;
}
// jQuery interface
$.fn[NAME] = MapAPI._jQueryInterface;
$.fn[NAME].Constructor = MapAPI;
$.fn[NAME].noConflict = function() {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return MapAPI._jQueryInterface;
};
getStyle() {
return 'mapbox://styles/mapbox/streets-v9';
const hour = new Date().getHours();
if(hour < 6 || hour > 18) {
// night
//return 'mapbox://styles/mapbox/streets-v7';
return 'mapbox://styles/tony-air/cjeacwih92iu42rpd8tcmuyb2';
}else{
// day
return 'mapbox://styles/mapbox/streets-v9';
}
}
// auto-apply
$(W).on(`${Events.AJAX} ${Events.LOADED}`, () => {
$('.mapAPI-map-container').jsMapAPI();
});
dispose() {
const $element = $(this._element);
$element.removeClass(`${NAME}-active`);
$.removeData(this._element, DATA_KEY);
this._element = null;
}
static _jQueryInterface() {
if (typeof W.localStorage !== 'undefined') {
return this.each(function () {
// attach functionality to element
const $element = $(this);
let data = $element.data(DATA_KEY);
if (!data) {
data = new MapAPI(this);
$element.data(DATA_KEY, data);
}
});
}
}
}
// jQuery interface
$.fn[NAME] = MapAPI._jQueryInterface;
$.fn[NAME].Constructor = MapAPI;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return MapAPI._jQueryInterface;
};
// auto-apply
$(W).on(`${Events.AJAX} ${Events.LOADED}`, () => {
$('.mapAPI-map-container').jsMapAPI();
});
return MapAPI;
return MapAPI;
})($);
export default MapAPI;

View File

@ -0,0 +1 @@
import '../_components/_ui.map.api';

View File

@ -16,10 +16,6 @@
.carousel-indicators li {
box-shadow: 1px 1px #000;
&.active {
background: $blue;
}
}
.carousel-title,

View File

@ -3,8 +3,12 @@
*/
// hide default page title cuz elemental object will be used to display titles
h1 {
h1.page-header {
display: none;
&.no-elements {
display: block;
}
}
// add top/bottom paddings for basic elements

View File

@ -37,6 +37,14 @@ button, input, optgroup, select, textarea,
transition: all 0.4s ease;
}
.btn-toolbar {
margin-top: $grid-gutter-height / 2;
}
.field {
margin: ($grid-gutter-height / 4) 0;
}
// stick navbar to top using mobile layout
#Header {
position: relative;

View File

@ -0,0 +1,15 @@
@import "../variables";
@import "~mapbox-gl/dist/mapbox-gl.css";
.mapAPI-map {
height: 30rem;
margin-bottom: 1rem;
}
.mapboxgl-marker {
width: 30px;
height: 30px;
font-size: 30px;
cursor: pointer;
text-align: center;
}

View File

@ -0,0 +1,8 @@
.cart-footer {
margin-top: $grid-gutter-height / 2;
}
.address-panel,
.account-nav {
margin-bottom: $grid-gutter-height / 2;
}

View File

@ -1 +0,0 @@
@import "../variables";

View File

@ -0,0 +1,163 @@
@import "../_variables";
h1.title {
display: block;
text-align: right;
border-bottom: 1px solid $border-color;
text-transform: uppercase;
line-height: 1.5em;
}
.warningMessage {
position: relative;
padding: $alert-padding-y $alert-padding-x;
margin-bottom: $alert-margin-bottom;
border: $alert-border-width solid transparent;
@include border-radius($alert-border-radius);
color: #856404;
background-color: #fff3cd;
border-color: #ffeeba;
}
#Content {
text-align: left;
margin: auto;
padding-left: 20px;
}
#Content td {}
#Content .emailTitle {
font-family: $font-family-base;
font-weight: normal;
font-size: $h1-font-size;
}
#Content .PageTitle {
padding: 5px;
color: $body-color;
font-size: 14px;
font-family: $font-family-base;
}
#Content .footer td {
padding: 10px;
}
#Content .footer td.right {
text-align: right;
}
#Content .typography {
padding: 0px 10px;
}
#Content .typography a {
font-size: 1em;
text-decoration: underline;
}
#Content .typography a:hover {
text-decoration: none;
}
#Content .typography ul {
padding: 2px 15px;
}
#Content .typography ul li {
padding: 2px 5px;
}
#Content .typography p {
margin: 0.75em 0em;
color: $body-color;
}
table#SenderTable .sender,
table#SenderTable .meta {
width: 50%;
}
table#MetaTable {
margin-left: auto;
}
table#MetaTable .label {
font-weight: bold;
}
#ShippingTable td,
#ShippingTable th {
width: 50%;
}
table.infotable {
border: 1px solid $border-color;
border-collapse: collapse;
width: 100%;
border-top: 1px solid $border-color;
border-bottom: 1px solid $border-color;
background: $body-bg;
margin-top: 10px;
}
table.infotable td.product.title {
color: $link-color;
font-size: $h3-font-size;
font-weight: normal;
font-family: $font-family-base;
}
table.infotable tr td,
table.infotable tr th {
padding: 5px;
color: $body-color;
border: 1px solid $border-color;
}
table.infotable td {
vertical-align: middle;
}
table.infotable tr.summary {
font-weight: bold;
}
table.infotable td.ordersummary {
font-size: 1em;
border-bottom: 1px solid $border-color;
}
table.infotable tr th {
font-weight: bold;
}
table.infotable tr td a {
color: $link-color;
text-decoration: underline;
}
table.infotable tr td a:hover {
text-decoration: none;
}
table.infotable .modifierRow,
table.infotable .threeColHeader {
text-align: right;
}
table.infotable .right {
text-align: right;
}
table.infotable .center {
text-align: center;
}
table.infotable .left,
table.infotable th {
text-align: left;
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Created by PhpStorm.
* User: tony
* Date: 8/26/18
* Time: 12:55 PM
*/
namespace Site\Extensions;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\CompositeField;
use SilverStripe\Forms\FieldList;
class AddressExtension extends Extension
{
public function updateFormFields(FieldList $fields)
{
$holder = CompositeField::create();
foreach ($fields as $field) {
$holder->push($field);
$fields->remove($field);
}
$holder->addExtraClass('col-sm-6');
$fields->push($holder);
}
}

View File

@ -2,20 +2,24 @@
namespace Site\Extensions;
use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Assets\Image;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TreeMultiselectField;
use BetterBrief\GoogleMapField;
class SiteConfigExtension extends DataExtension
{
private static $db = [
'ExtraCode' => 'Text',
];
private static $has_one = [
'PrivacyPolicy' => SiteTree::class,
'Longitude' => 'Varchar(255)',
'Latitude' => 'Varchar(255)',
'MapZoom' => 'Int',
'MapAPIKey' => 'Varchar(255)'
];
private static $many_many = [
@ -32,8 +36,29 @@ class SiteConfigExtension extends DataExtension
SiteTree::class
));
$tab->push(TreeDropdownField::create('PrivacyPolicyID', 'Select privacy policy page', SiteTree::class));
$tab->push(TextareaField::create('ExtraCode', 'Extra site-wide HTML code'));
$mapTab = $fields->findOrMakeTab('Root.GoogleMaps');
$mapTab->push(TextField::create('MapAPIKey'));
$mapTab->push(TextField::create('MapZoom'));
$mapTab->push(GoogleMapField::create(
$this->owner,
'Location'
));
}
public function getGeoJSON()
{
return '{"type": "MarkerCollection","features": [{"type": "Feature","icon": "<i class=\'fas fa-map-marker-alt\'></i>",'
.'"properties": {"content": "'.$this->owner->getTitle().'"},"geometry": {"type": "Point",'
.'"coordinates": ['.$this->owner->getField('Longitude').','.$this->owner->getField('Latitude').']}}]}';
}
public function DirectionsLink()
{
return '<a href="https://www.google.com/maps/dir/Current+Location/'
.$this->owner->getField('Latitude').','
.$this->owner->getField('Longitude').'" class="btn btn-primary btn-directions" target="_blank">'
.'<i class="fas fa-road"></i> Get Directions</a>';
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Created by PhpStorm.
* User: tony
* Date: 8/26/18
* Time: 1:40 PM
*/
namespace Site\Models;
use SilverShop\Checkout\Component\CheckoutComponent;
use SilverShop\Model\Order;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HeaderField;
use SilverStripe\Forms\LiteralField;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\SSViewer;
class CheckoutMapComponent extends CheckoutComponent
{
public function getFormFields(Order $order)
{
$config = SiteConfig::current_site_config();
return FieldList::create(
HeaderField::create('MapHeader', 'Pick up location'),
LiteralField::create(
'Map',
SSViewer::create('Objects\Map')->process($config)
)
);
}
public function validateData(Order $order, array $data)
{
}
public function setData(Order $order, array $data)
{
}
public function getData(Order $order)
{
return [];
}
}

View File

@ -0,0 +1,43 @@
<?php
/**
* Created by PhpStorm.
* User: tony
* Date: 8/26/18
* Time: 1:08 PM
*/
namespace Site\Models;
use SilverShop\Checkout\Checkout;
use SilverShop\Checkout\CheckoutComponentConfig;
use SilverShop\Checkout\Component\CustomerDetails;
use SilverShop\Checkout\Component\Notes;
use SilverShop\Checkout\Component\Payment;
use SilverShop\Checkout\Component\Terms;
use SilverShop\Checkout\Component\Membership;
use SilverShop\Model\Order;
use SilverStripe\Omnipay\GatewayInfo;
use SilverStripe\Security\Security;
class CheckoutNoDeliveryConfig extends CheckoutComponentConfig
{
public function __construct(Order $order)
{
parent::__construct($order);
$this->addComponent(CustomerDetails::create());
if (Checkout::member_creation_enabled() && !Security::getCurrentUser()) {
$this->addComponent(Membership::create());
}
if (count(GatewayInfo::getSupportedGateways()) > 1) {
$this->addComponent(Payment::create());
}
$this->addComponent(Notes::create());
$this->addComponent(CheckoutMapComponent::create());
$this->addComponent(Terms::create());
}
}

View File

@ -19,6 +19,7 @@ class DeferedRequirements implements TemplateGlobalProvider
private static $version;
private static $nojquery = false;
private static $nofontawesome = false;
private static $custom_requirements = [];
/**
* @return array
@ -55,7 +56,19 @@ class DeferedRequirements implements TemplateGlobalProvider
DeferedRequirements::loadJS('app.js');
// Class libs
$class = str_replace('\\', '.', get_class(Controller::curr()));
$class = get_class(Controller::curr());
if(isset($config['custom_requirements'][$class])){
foreach ($config['custom_requirements'][$class] as $file) {
if(strpos($file,'.css')){
DeferedRequirements::loadCSS($file);
}
if(strpos($file,'.js')){
DeferedRequirements::loadJS($file);
}
}
}
$class = str_replace('\\', '.', $class);
$dir = Path::join(
Director::publicFolder(),
ManifestFileFinder::RESOURCES_DIR,
@ -64,8 +77,8 @@ class DeferedRequirements implements TemplateGlobalProvider
'dist'
);
if (file_exists(Path::join($dir, 'css', '_' . $class . '.css'))) {
DeferedRequirements::loadCSS('_' . $class . '.css');
if (file_exists(Path::join($dir, 'css', $class . '.css'))) {
DeferedRequirements::loadCSS( $class . '.css');
}
if (file_exists(Path::join($dir, 'js', $class . '.js'))) {

View File

@ -1,11 +1,11 @@
<div class="page-content">
<h1 class="page-header">$Title</h1>
<h1 class="page-header container<% if $ElementalArea.Elements.Count < 1 %> no-elements<% end_if %>">$Title</h1>
<div class="page-content">
<div class="page-content">
$ElementalArea
<% if $Form %>
<div class="form-container container">
<div class="container">
$Form
</div>
<% end_if %>
@ -15,6 +15,6 @@
$ExtraCode
</div>
<% end_if %>
</div>
</div>
</div>

View File

@ -5,7 +5,7 @@
<% include MetaHead %>
</head>
<body oncontextmenu="return false;">
<body oncontextmenu="return false;"<% with $SiteConfig %> data-default-lng="$Longitude" data-default-lat="$Latitude"<% end_with %>>
<%-- Upgrade your Browser notice --%>
<!--[if lt IE 10]><div class="main-bn"><a href="https://www.google.com/chrome/browser/desktop/" title="<%t Page.UPGRADEBROWSER 'Upgrade your browser' %>"><%t Page.OUTDATEDBROWSER 'You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today.' %></a></div><![endif]-->
@ -36,6 +36,10 @@
<%-- Require CSS+JS from /public/resourses/[js,css]/[ClassName].[js,css] --%>
$AutoRequirements($ClassName).RAW
<%-- Mapbox --%>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.js"></script>
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.css" rel="stylesheet" />
<%-- place extra requirements after this line --%>
<div class="extra-code extra-code-site">
$SiteConfig.ExtraCode

View File

@ -1,5 +1,5 @@
<% if $Items %>
<table class="cart" summary="<%t SilverShop\Cart\ShoppingCart.TableSummary "Current contents of your cart." %>">
<table class="cart table table-striped table-bordered table-hover" summary="<%t SilverShop\Cart\ShoppingCart.TableSummary "Current contents of your cart." %>">
<colgroup>
<col class="image"/>
<col class="product title"/>
@ -27,7 +27,7 @@
<% if $Image %>
<div class="image">
<a href="$Link" title="<%t SilverShop\Generic.ReadMoreTitle "Click here to read more on &quot;{Title}&quot;" Title=$TableTitle %>">
$Image.setWidth(45)
$Image.Fill(100,100)
</a>
</div>
<% end_if %>
@ -54,7 +54,7 @@
$RemoveField
<% else %>
<a href="$removeallLink" title="<%t SilverShop\Cart\ShoppingCart.RemoveAllTitle "Remove all of &quot;{Title}&quot; from your cart" Title=$TableTitle %>">
<img src="$resourceURL('silvershop/core:client/dist/images/remove.gif')" alt="x"/>
<i class="fas fa-times"></i>
</a>
<% end_if %>
@ -111,7 +111,7 @@
</tfoot>
</table>
<% else %>
<p class="message warning">
<div class="alert alert-warning message warning">
<%t SilverShop\Cart\ShoppingCart.NoItems "There are no items in your cart." %>
</p>
</div>
<% end_if %>

View File

@ -1,47 +1,28 @@
<div class="accountnav">
<div class="nav">
<h2><%t SilverShop\Page\AccountPage.Title 'My Account' %></h2>
<ul class="nav nav-list">
<li>
<a href="{$Link}">
<i class="icon icon-list fa fa-list"></i><%t SilverShop\Page\AccountPage.PastOrders 'Past Orders' %>
</a>
</li>
<li>
<a href="{$Link('editprofile')}">
<i class="icon icon-user fa fa-user"></i><%t SilverShop\Page\AccountPage.EditProfile 'Edit Profile' %>
</a>
</li>
<li>
<a href="{$Link('addressbook')}">
<i class="icon icon-book fa fa-book"></i><%t SilverShop\Page\AccountPage.AddressBook 'Address Book' %>
</a>
</li>
<li>
<a href="Security/logout">
<i class="icon icon-off fa fa-sign-out"></i><%t SilverShop\Page\AccountPage.LogOut 'Log Out' %>
</a>
</li>
</ul>
</div>
<div class="memberdetails">
<% with $CurrentMember %>
<dl>
<dt><%t SilverShop\Page\AccountPage.MemberName 'Name' %></dt>
<dd>$Name</dd>
<dt><%t SilverShop\Page\AccountPage.MemberEmail 'Email' %></dt>
<dd>$Email</dd>
<dt><%t SilverShop\Page\AccountPage.MemberSince 'Member Since' %></dt>
<dd>$Created.Nice</dd>
<dt><%t SilverShop\Page\AccountPage.MemberLastVisit 'Last Visit' %></dt>
<dd>$LastVisited.Nice</dd>
<dt> <%t SilverShop\Page\AccountPage.NumberOfOrders 'Number of orders' %></dt>
<dd><% if $PastOrders %>{$PastOrders.Count}<% else %>0<% end_if %></dd>
</dl>
<% end_with %>
</div>
</div>
<nav class="account-nav">
<ul class="nav nav-tabs">
<li class="nav-item">
<a href="{$Link}" class="nav-link<% if $Action == 'index' %> active<% end_if %>">
<i class="fas fa-list"></i>
<%t SilverShop\Page\AccountPage.PastOrders 'Past Orders' %>
</a>
</li>
<li class="nav-item">
<a href="{$Link('editprofile')}" class="nav-link<% if $Action == 'editprofile' %> active<% end_if %>">
<i class="fas fa-user"></i>
<%t SilverShop\Page\AccountPage.EditProfile 'Edit Profile' %>
</a>
</li>
<li class="nav-item">
<a href="{$Link('addressbook')}" class="nav-link<% if $Action == 'addressbook' %> active<% end_if %>">
<i class="fas fa-book"></i>
<%t SilverShop\Page\AccountPage.AddressBook 'Address Book' %>
</a>
</li>
<li class="nav-item">
<a href="Security/logout" class="nav-link">
<i class="fas fa-sign-out-alt"></i>
<%t SilverShop\Page\AccountPage.LogOut 'Log Out' %>
</a>
</li>
</ul>
</nav>

View File

@ -17,7 +17,7 @@
<td>$Items.Quantity</td>
<td>$Total.Nice</td>
<td>$StatusI18N</td>
<td>
<td class="text-right">
<a class="btn btn-mini btn-primary" href="$Link">
<i class="icon icon-white icon-eye-open fa fa-eye"></i> <%t SilverShop\Generic.View 'view' %>
</a>

View File

@ -1,8 +1,9 @@
<% require css("silvershop/core: client/dist/css/order.css") %>
<% require css("app/client/dist/css/order.css") %>
<%-- As Order.ss is also used in emails, avoid div, paragraph and heading elements --%>
<% include SilverShop\Model\Order_Address %>
<% include SilverShop\Model\Order_Content %>
<% if $Total %>
<% if $Payments %>
<% include SilverShop\Model\Order_Payments %>

View File

@ -2,7 +2,7 @@
<td class="image">
<% if $Image %>
<a href="$Link" title="<%t SilverShop\Generic.ReadMoreTitle "Click here to read more on &quot;{Title}&quot;" Title=$TableTitle %>">
<img src="<% with $Image.setWidth(45) %>$Me.AbsoluteURL<% end_with %>" alt="$Buyable.Title"/>
<img src="$Image.Fill(100,100).AbsoluteURL" alt="$Buyable.Title"/>
</a>
<% end_if %>
</td>

View File

@ -1,21 +1,25 @@
<div class="container page-content">
<div class="page-content">
<div class="account element">
<% include SilverShop\Includes\AccountNavigation %>
<div class="container">
<% include SilverShop\Includes\AccountNavigation %>
</div>
<% include Content %>
<h2 class="page-header">
<%t SilverShop\Page\AccountPage.PastOrders 'Past Orders' %>
</h2>
<div class="container">
<h2 class="page-header">
<%t SilverShop\Page\AccountPage.PastOrders 'Past Orders' %>
</h2>
<% with $Member %>
<% if $PastOrders %>
<% include SilverShop\Includes\OrderHistory %>
<% else %>
<div class="alert alert-warning message warning">
<%t SilverShop\Page\AccountPage.NoPastOrders 'No past orders found.' %>
</div>
<% end_if %>
<% end_with %>
<% with $Member %>
<% if $PastOrders %>
<% include SilverShop\Includes\OrderHistory %>
<% else %>
<div class="alert alert-warning message warning">
<%t SilverShop\Page\AccountPage.NoPastOrders 'No past orders found.' %>
</div>
<% end_if %>
<% end_with %>
</div>
</div>
</div>

View File

@ -2,72 +2,78 @@
<div class="account element">
<% include SilverShop\Includes\AccountNavigation %>
<div class="row">
<div class="col-sm-6">
<h2 class="pagetitle">
<%t SilverShop\Page\AccountPage_AddressBook.Title 'Default Addresses' %>
</h2>
<h2 class="pagetitle">
<%t SilverShop\Page\AccountPage_AddressBook.Title 'Default Addresses' %>
</h2>
<%-- If you want the old dropdown system back you can just use $DefaultAddressForm here instead --%>
<% if $CurrentMember.AddressBook %>
<% loop $CurrentMember.AddressBook %>
<div class="card radius address-panel $EvenOdd">
<div class="card-body">
<% if $ID == $CurrentMember.DefaultShippingAddressID %>
<h5 class="card-title tag def-shipping">
<%t SilverShop\Page\AccountPage_AddressBook.DefaultShippingAddress 'Default Shipping Address' %>
</h5>
<% end_if %>
<%-- If you want the old dropdown system back you can just use $DefaultAddressForm here instead --%>
<% if $CurrentMember.AddressBook %>
<% loop $CurrentMember.AddressBook %>
<div class="panel radius address-panel $EvenOdd">
<% if $ID == $CurrentMember.DefaultShippingAddressID %>
<span class="tag def-shipping">
<%t SilverShop\Page\AccountPage_AddressBook.DefaultShippingAddress 'Default Shipping Address' %>
</span>
<% end_if %>
<% if $ID == $CurrentMember.DefaultBillingAddressID %>
<h5 class="card-title tag def-billing">
<%t SilverShop\Page\AccountPage_AddressBook.DefaultBillingAddress 'Default Billing Address' %>
</h5>
<% end_if %>
<% if $ID == $CurrentMember.DefaultBillingAddressID %>
<span class="tag def-billing">
<%t SilverShop\Page\AccountPage_AddressBook.DefaultBillingAddress 'Default Billing Address' %>
</span>
<% end_if %>
<div class="card-text">
<% include SilverShop\Model\Address %>
</div>
<div class="panel-body">
<% include SilverShop\Model\Address %>
<% if $ID != $CurrentMember.DefaultShippingAddressID %>
<a
title="<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultShippingTitle 'Make this my default shipping address' %>"
href="account/setdefaultshipping/{$ID}"
class="card-link"
>
<i class="fas fa-check"></i>
<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultShipping 'Make Default Shipping' %>
</a>
<% end_if %>
<% if $ID != $CurrentMember.DefaultBillingAddressID %>
<a
title="<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultBillingTitle 'Make this my default billing address' %>"
href="account/setdefaultbilling/{$ID}"
class="card-link"
>
<i class="fas fa-check"></i>
<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultBilling 'Make Default Billing' %>
</a>
<% end_if %>
<a
href="account/deleteaddress/{$ID}"
class="remove-address card-link"
title="<%t SilverShop\Page\AccountPage_AddressBook.DeleteAddress 'Delete this address' %>"
>
<i class="fas fa-times"></i>
<%t SilverShop\Page\AccountPage_AddressBook.DeleteAddress 'Delete this address' %>
</a>
</div>
</div>
<% end_loop %>
<% else %>
<div class="alert alert-warning">
<%t SilverShop\Page\AccountPage_AddressBook.NoAddress 'No addresses found.' %>
</div>
<div class="panel-footer cf">
<% if $ID != $CurrentMember.DefaultShippingAddressID %>
<a
title="<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultShippingTitle 'Make this my default shipping address' %>"
href="account/setdefaultshipping/{$ID}"
class="btn btn-primary"
>
<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultShipping 'Make Default Shipping' %>
</a>
<% end_if %>
<% if $ID != $CurrentMember.DefaultBillingAddressID %>
<a
title="<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultBillingTitle 'Make this my default billing address' %>"
href="account/setdefaultbilling/{$ID}"
class="btn btn-primary"
>
<%t SilverShop\Page\AccountPage_AddressBook.MakeDefaultBilling 'Make Default Billing' %>
</a>
<% end_if %>
<a
href="account/deleteaddress/{$ID}"
class="remove-address"
title="<%t SilverShop\Page\AccountPage_AddressBook.DeleteAddress 'Delete this address' %>"
>
<i class="fas fa-times"></i>
</a>
</div>
</div>
<% end_loop %>
<% else %>
<div class="alert alert-warning">
<%t SilverShop\Page\AccountPage_AddressBook.NoAddress 'No addresses found.' %>
<% end_if %>
</div>
<% end_if %>
<h2>
<%t SilverShop\Page\AccountPage_AddressBook.CreateNewTitle 'Create New Address' %>
</h2>
<div class="col-sm-6">
<h2><%t SilverShop\Page\AccountPage_AddressBook.CreateNewTitle 'Create New Address' %></h2>
$CreateAddressForm
$CreateAddressForm
</div>
</div>
</div>
</div>

View File

@ -2,11 +2,43 @@
<div class="element account">
<% include SilverShop\Includes\AccountNavigation %>
<h2 class="pagetitle">
<%t SilverShop\Page\AccountPage_EditProfile.Title 'Edit Profile' %>
</h2>
<div class="row">
<div class="col-sm-6">
<h2><%t SilverShop\Page\AccountPage.Title 'My Account' %></h2>
<div class="card memberdetails">
<div class="card-body">
<div class="card-text">
<% with $CurrentMember %>
<dl>
<dt><%t SilverShop\Page\AccountPage.MemberName 'Name' %></dt>
<dd>$Name</dd>
$EditAccountForm
$ChangePasswordForm
<dt><%t SilverShop\Page\AccountPage.MemberEmail 'Email' %></dt>
<dd>$Email</dd>
<dt><%t SilverShop\Page\AccountPage.MemberSince 'Member Since' %></dt>
<dd>$Created.Nice</dd>
<%-- dt><%t SilverShop\Page\AccountPage.MemberLastVisit 'Last Visit' %></dt>
<dd>$LastVisited.Nice</dd --%>
<dt> <%t SilverShop\Page\AccountPage.NumberOfOrders 'Number of orders' %></dt>
<dd><% if $PastOrders %>{$PastOrders.Count}<% else %>0<% end_if %></dd>
</dl>
<% end_with %>
</div>
</div>
</div>
$ChangePasswordForm
</div>
<div class="col-sm-6">
<h2 class="pagetitle">
<%t SilverShop\Page\AccountPage_EditProfile.Title 'Edit Profile' %>
</h2>
$EditAccountForm
</div>
</div>
</div>
</div>

View File

@ -14,6 +14,10 @@
<% with $Order %>
<% include SilverShop\Model\Order %>
<% end_with %>
<% with $SiteConfig %>
<% include Objects\Map %>
<% end_with %>
$ActionsForm
<% end_if %>
</div>

View File

@ -1,35 +1,37 @@
<div class="container page-content">
<div class="page-content">
<div class="element cart-page">
<% include Content %>
<% if $Cart %>
<% if $CartForm %>
$CartForm
<% else %>
<% with $Cart %><% include SilverShop\Cart\Cart Editable=true %><% end_with %>
<% end_if %>
<% else %>
<div class="alert alert-warning message warning"><%t SilverShop\Cart\ShoppingCart.NoItems "There are no items in your cart." %></div>
<% end_if %>
<div class="cartfooter">
<% if $ContinueLink %>
<a class="continuelink btn btn-primary" href="$ContinueLink">
<i class="fas fa-chevron-left"></i>
<%t SilverShop\Cart\ShoppingCart.ContinueShopping 'Continue Shopping' %>
</a>
<% end_if %>
<div class="container">
<% if $Cart %>
<% if $CheckoutLink %>
<a class="checkoutlink btn btn-primary" href="$CheckoutLink">
<i class="fas fa-chevron-right"></i>
<%t SilverShop\Cart\ShoppingCart.ProceedToCheckout 'Proceed to Checkout' %>
<% if $CartForm %>
$CartForm
<% else %>
<% with $Cart %><% include SilverShop\Cart\Cart Editable=true %><% end_with %>
<% end_if %>
<% else %>
<div class="alert alert-warning message warning"><%t SilverShop\Cart\ShoppingCart.NoItems "There are no items in your cart." %></div>
<% end_if %>
<div class="cart-footer">
<% if $ContinueLink %>
<a class="continuelink btn btn-primary" href="$ContinueLink">
<i class="fas fa-chevron-left"></i>
<%t SilverShop\Cart\ShoppingCart.ContinueShopping 'Continue Shopping' %>
</a>
<% end_if %>
<% end_if %>
<% if $Cart %>
<% if $CheckoutLink %>
<a class="checkoutlink btn btn-primary" href="$CheckoutLink">
<%t SilverShop\Cart\ShoppingCart.ProceedToCheckout 'Proceed to Checkout' %>
<i class="fas fa-chevron-right"></i>
</a>
<% end_if %>
<% end_if %>
</div>
</div>
</div>
</div>

View File

@ -1,14 +1,17 @@
<div class="page-content container">
<div class="page-content">
<div class="checkout element">
<% if $PaymentErrorMessage %>
<div class="container">
<div class="alert alert-danger message error">
<%t SilverShop\Page\CheckoutPage.PaymentErrorMessage 'Received error from payment gateway:' %>
$PaymentErrorMessage
</div>
</div>
<% end_if %>
<% include Content %>
<div class="container">
<% if $Cart %>
<% with $Cart %>
<% include SilverShop\Cart\Cart ShowSubtotals=true %>
@ -18,5 +21,6 @@
<% else %>
<div class="alert alert-warning message warning"><%t SilverShop\Cart\ShoppingCart.NoItems "There are no items in your cart." %></div>
<% end_if %>
</div>
</div>
</div>

View File

@ -33,6 +33,7 @@
"jquery": "^3.3.1",
"jquery-hammerjs": "^2.0.0",
"jquery-zoom": "^1.7.21",
"mapbox-gl": "^0.48.0",
"meta-lightbox": "^1.0.0",
"offcanvas-bootstrap": "^2.5.2",
"popper.js": "^1.14.3",

4
php.ini Normal file
View File

@ -0,0 +1,4 @@
date.timezone = "America/New_York"
display_errors = Off
magic_quotes_gpc = Off
expose_php = Off