Skip to content

Commit

Permalink
Merge branch 'feature/theming-fixes' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dshoreman committed Oct 19, 2014
2 parents 2267ffa + d6370c1 commit 81c77f3
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 76 deletions.
32 changes: 32 additions & 0 deletions components/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ public function defineProperties()
'default' => 'shop/product',
'group' => 'Links',
],
'tableClass' => [
'title' => 'Table',
'group' => 'CSS Classes',
],
'nameColClass' => [
'title' => 'Name Column',
'group' => 'CSS Classes',
],
'qtyColClass' => [
'title' => 'Quaantity Column',
'group' => 'CSS Classes',
],
'priceColClass' => [
'title' => 'Price Column',
'group' => 'CSS Classes',
],
'subtotalColClass' => [
'title' => 'Subtotal Column',
'group' => 'CSS Classes',
],
'totalLabelClass' => [
'title' => 'Total Label',
'group' => 'CSS Classes',
'description' => 'Class given to the cell containing the "Total" label.',
],
];
}

Expand All @@ -54,6 +79,13 @@ public function prepareVars()
$this->paymentPage = $this->page['paymentPage'] = $this->property('paymentPage');
$this->productPage = $this->page['productPage'] = $this->property('productPage');

$this->tableClass = $this->page['tableClass'] = $this->property('tableClass');
$this->nameColClass = $this->page['nameColClass'] = $this->property('nameColClass');
$this->qtyColClass = $this->page['qtyColClass'] = $this->property('qtyColClass');
$this->priceColClass = $this->page['priceColClass'] = $this->property('priceColClass');
$this->subtotalColClass = $this->page['subtotalColClass'] = $this->property('subtotalColClass');
$this->totalLabelClass = $this->page['totalLabelClass'] = $this->property('totalLabelClass');

$this->basketItems = $this->page['basketItems'] = Cart::content();
$this->basketCount = $this->page['basketCount'] = Cart::count();
$this->basketTotal = $this->page['basketTotal'] = Cart::total();
Expand Down
80 changes: 79 additions & 1 deletion components/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,91 @@ public function defineProperties()
'default' => ':slug',
'type' => 'string',
],
'basketContainer' => [
'title' => 'Basket container element',
'description' => 'Basket container element to update when adding products to cart',
],
'addButtonText' => [
'title' => 'Buy button text',
],
'rowClass' => [
'title' => 'Row',
'group' => 'CSS Classes',
'default' => 'row',
],
'imageClass' => [
'title' => 'Image',
'group' => 'CSS Classes',
],
'productContainerClass' => [
'title' => 'Product container',
'group' => 'CSS Classes',
],
'detailContainerClass' => [
'title' => 'Detail container',
'group' => 'CSS Classes',
],
'priceClass' => [
'title' => 'Price',
'group' => 'CSS Classes',
],
'priceContainerClass' => [
'title' => 'Price container',
'group' => 'CSS Classes',
],
'qtyClass' => [
'title' => 'Quantity',
'group' => 'CSS Classes',
],
'qtyWrapperClass' => [
'title' => 'Quantity Wrapper',
'group' => 'CSS Classes',
],
'qtyLabelClass' => [
'title' => 'Quantity Label',
'group' => 'CSS Classes',
],
'qtyContainerClass' => [
'title' => 'Quantity container',
'group' => 'CSS Classes',
],
'addButtonClass' => [
'title' => 'Buy button',
'group' => 'CSS Classes',
],
'addButtonContainerClass' => [
'title' => 'Buy button container',
'group' => 'CSS Classes',
],
];
}

public function onRun() {
public function onRun()
{
$this->prepareVars();

$this->product = $this->page['product'] = $this->loadProduct();
}

public function prepareVars()
{
$this->basketContainer = $this->page['basketContainer'] = $this->property('basketContainer');
$this->addButtonText = $this->page['addButtonText'] = $this->property('addButtonText');
$this->rowClass = $this->page['rowClass'] = $this->property('rowClass');
$this->imageClass = $this->page['imageClass'] = $this->property('imageClass');
$this->imageContainerClass = $this->page['imageContainerClass'] = $this->property('imageContainerClass');
$this->productContainerClass = $this->page['productContainerClass'] = $this->property('productContainerClass');
$this->detailContainerClass = $this->page['detailContainerClass'] = $this->property('detailContainerClass');
$this->qtyClass= $this->page['qtyClass'] = $this->property('qtyClass');
$this->qtyWrapperClass= $this->page['qtyWrapperClass'] = $this->property('qtyWrapperClass');
$this->qtyLabelClass= $this->page['qtyLabelClass'] = $this->property('qtyLabelClass');
$this->qtyContainerClass = $this->page['qtyContainerClass'] = $this->property('qtyContainerClass');
$this->priceClass= $this->page['priceClass'] = $this->property('priceClass');
$this->priceContainerClass = $this->page['priceContainerClass'] = $this->property('priceContainerClass');
$this->addButtonContainerClass = $this->page['addButtonContainerClass'] = $this->property('addButtonContainerClass');
$this->addButtonClass = $this->page['addButtonClass'] = $this->property('addButtonClass');
}

public function loadProduct()
{
$productId = $this->propertyOrParam('idParam');
Expand Down
56 changes: 5 additions & 51 deletions components/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use DShoreman\Shop\Models\Category as ShopCategory;
use DShoreman\Shop\Models\Product as ShopProduct;

class Products extends ComponentBase
class Products extends Product
{

public function componentDetails()
Expand All @@ -18,64 +18,25 @@ public function componentDetails()

public function defineProperties()
{
return [
return array_merge(parent::defineProperties(), [
'categoryFilter' => [
'title' => 'Category filter',
'description' => 'Enter a category slug or URL parameter to filter the posts by. Leave empty to show all posts.',
'type' => 'string',
'default' => ''
],
'basketContainer' => [
'title' => 'Basket container element to update when adding products to cart',
],
'addButtonText' => [
'title' => 'Buy button text',
],
'productPage' => [
'title' => 'Product Page',
'description' => 'Name of the product page for the product titles. This property is used by the default component partial.',
'type' => 'dropdown',
'default' => 'shop/product',
'group' => 'Links',
],
'imageClass' => [
'title' => 'Image',
'group' => 'CSS Classes',
],
'rowClass' => [
'title' => 'Row',
'group' => 'CSS Classes',
'default' => 'row',
],
'productColumnClass' => [
'title' => 'Product column',
'group' => 'CSS Classes',
],
'productContainerClass' => [
'title' => 'Product container',
'group' => 'CSS Classes',
],
'detailContainerClass' => [
'title' => 'Detail container',
'group' => 'CSS Classes',
],
'priceClass' => [
'title' => 'Price',
'group' => 'CSS Classes',
],
'priceContainerClass' => [
'title' => 'Price container',
'group' => 'CSS Classes',
],
'addButtonClass' => [
'title' => 'Buy button',
'group' => 'CSS Classes',
],
'addButtonContainerClass' => [
'title' => 'Buy button container',
'group' => 'CSS Classes',
],
];
]);
}

public function getProductPageOptions()
Expand All @@ -94,19 +55,12 @@ public function onRun()

public function prepareVars()
{
parent::prepareVars();

$this->productPage = $this->page['productPage'] = $this->property('productPage');
$this->category = $this->page['category'] = $this->loadCategory();

$this->productColumnClass = $this->page['productColumnClass'] = $this->property('productColumnClass');
$this->productContainerClass = $this->page['productContainerClass'] = $this->property('productContainerClass');
$this->imageClass = $this->page['imageClass'] = $this->property('imageClass');
$this->detailContainerClass = $this->page['detailContainerClass'] = $this->property('detailContainerClass');
$this->rowClass = $this->page['rowClass'] = $this->property('rowClass');
$this->priceContainerClass = $this->page['priceContainerClass'] = $this->property('priceContainerClass');
$this->addButtonContainerClass = $this->page['addButtonContainerClass'] = $this->property('addButtonContainerClass');
$this->addButtonClass = $this->page['addButtonClass'] = $this->property('addButtonClass');
$this->basketContainer = $this->page['basketContainer'] = $this->property('basketContainer');
$this->addButtonText = $this->page['addButtonText'] = $this->property('addButtonText');
}

public function loadCategory()
Expand Down
20 changes: 11 additions & 9 deletions components/basket/default.htm
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<p>You have {{ basketCount }} item(s) in your basket!</p>

<table class="table">
<table class="{{ tableClass }}">
<thead>
<tr>
<th>Product</th>
<th>Qty.</th>
<th>Price</th>
<th>Subtotal</th>
<th class="{{ nameColClass }}">Product</th>
<th class="{{ qtyColClass }}">Qty.</th>
<th class="{{ priceColClass }}">Price</th>
<th class="{{ subtotalColClass }}">Subtotal</th>
</tr>
</thead>
<tbody>
Expand All @@ -18,7 +16,11 @@
<td>{{ item.subtotal }}</td>
</tr>
{% endfor %}
<tr>
<td colspan="3">
<strong class="{{ totalLabelClass }}">Total:</strong>
</td>
<td>&pound;{{ basketTotal }}</td>
</tr>
</tbody>
</table>

<p><strong>Total:</strong> &pound;{{ basketTotal }}</p>
32 changes: 17 additions & 15 deletions components/product/default.htm
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
<div class="row">
<div class="col-md-6">
<img class="img-rounded" src="http://placehold.it/500/500" />
<div class="{{ productContainerClass }}">
<div class="{{ imageContainerClass }}">
<img class="{{ imageClass }}" alt="{{ product.title }}" src="http://placehold.it/500/500" />
</div>
<div class="col-md-6">
<div class="{{ detailContainerClass }}">

<h2>{{ product.title }}</h2>

{{ product.description|raw }}

<form
data-request="shopBasket::onAddProduct"
data-request-update="'shopBasket::default' : '#basket'"
{% if basketContainer %}
data-request-update="'shopBasket::default' : '{{ basketContainer }}'"
{% endif %}
data-request-data="id: {{ product.id }}"
>
<div class="row">
<div class="col-md-3">
<p class="text-primary lead">
<div class="{{ rowClass }}">
<div class="{{ priceContainerClass }}">
<p class="{{ priceClass }}">
<strong>&pound; {{ product.price }}</strong>
</p>
</div>
<div class="col-md-4">
<label class="sr-only" for="qty">Quantity</label>
<div class="input-group product-qty">
<input type="number" class="form-control"
<div class="{{ qtyContainerClass }}">
<label class="{{ qtyLabelClass }}" for="qty">Quantity</label>
<div class="{{ qtyWrapperClass }}">
<input type="number" class="{{ qtyClass }}"
name="quantity" placeholder="Qty"
>
</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<button type="submit" class="btn btn-primary btn-block">Add to Cart</button>
<div class="{{ rowClass }}">
<div class="{{ addButtonContainerClass }}">
<button type="submit" class="{{ addButtonClass }}">{{ addButtonText }}</button>
</div>
</div>
</form>
Expand Down

0 comments on commit 81c77f3

Please sign in to comment.