Skip to content

Commit

Permalink
Merge branch 'release/0.1.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dshoreman committed Dec 4, 2014
2 parents 377fcb2 + 25749cd commit 73cd792
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 25 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Octoshop - A Shop Plugin for October CMS

Pretty much does what it says on the tin. Octoshop adds all the basic functionality
needed to sell products from your website running on October CMS. Still in its infancy,
it's fairly barebones right now, though the process from browsing to buying is already
covered. Payments are powered by Stripe JS for now, letting me spend more time worrying
about the things that matter most.


## Demo

Frontend: http://octoshop.demo.dsdev.io/
Backend: http://octoshop.demo.dsdev.io/backend/

Username and password for the backend are both `admin`.


## Documentation

Not yet... Check out the demo, browse the source, and have a gander at the optional
[theme](https://github.com/dshoreman/octoshop-theme) if you want to play about.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
53 changes: 39 additions & 14 deletions components/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,45 @@ public function onRender()
public function prepareVars($on = 'run')
{
if ($on == 'run') {
$this->paymentPage = $this->page['paymentPage'] = $this->property('paymentPage');
$this->productPage = $this->page['productPage'] = $this->property('productPage');
$this->registerBasketInfo();
$this->registerPages();

$this->basketComponent = $this->page['basketComponent'] = $this->property('basketComponent');;
$this->basketPartial = $this->page['basketPartial'] = $this->property('basketPartial');;
$this->basketItems = $this->page['basketItems'] = Cart::content();
$this->basketCount = $this->page['basketCount'] = Cart::count();
$this->basketTotal = $this->page['basketTotal'] = Cart::total();
}

if ($on == 'render') {
$this->tableClass = $this->page['tableClass'] = $this->propertyOrParam('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->registerClasses();
}

if (Session::has('orderId')) {
$this->orderId = $this->page['orderId'] = Session::get('orderId');
}
}

public function registerBasketInfo()
{
$this->basketCount = $this->page['basketCount'] = Cart::count();
$this->basketItems = $this->page['basketItems'] = Cart::content();
$this->basketTotal = $this->page['basketTotal'] = Cart::total();
}

public function registerPages()
{
$this->paymentPage = $this->page['paymentPage'] = $this->property('paymentPage');
$this->productPage = $this->page['productPage'] = $this->property('productPage');
}

public function registerClasses()
{
$this->tableClass = $this->page['tableClass'] = $this->propertyOrParam('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');
}

public function onAddProduct()
{
$id = post('id');
Expand All @@ -125,9 +140,19 @@ public function onAddProduct()

Cart::add($id, $product->title, $quantity, $product->price);

$this->page['basketCount'] = Cart::count();
$this->page['basketItems'] = Cart::content();
$this->page['basketTotal'] = Cart::total();
$this->registerBasketInfo();
}

public function onRemoveProduct()
{
Cart::remove(post('row_id'));

$this->registerBasketInfo();

return [
'total' => $this->basketTotal,
'count' => $this->basketCount,
];
}

public function onCheckout()
Expand Down
15 changes: 12 additions & 3 deletions components/basket/default.htm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<table class="{{ tableClass }}">
<thead>
<tr>
<th class="col-xs-1">&nbsp;</th>
<th class="{{ nameColClass }}">Product</th>
<th class="{{ qtyColClass }}">Qty.</th>
<th class="{{ priceColClass }}">Price</th>
Expand All @@ -9,18 +10,26 @@
</thead>
<tbody>
{% for item in basketItems %}
<tr>
<tr class="ocshop-row-{{ item.rowid }}">
<td>
<button type="submit" class="btn btn-xs btn-default"
data-request="{{ __SELF__ }}::onRemoveProduct"
data-request-data="row_id: '{{ item.rowid }}'"
data-request-success="$('.ocshop-row-{{ item.rowid }}').remove(); $('.ocshop-total').text(data.total); $('.ocshop-count').text(data.count);">
<span class="glyphicon glyphicon-remove"></span>
</button>
</td>
<td>{{ item.name }}</td>
<td>{{ item.qty }}</td>
<td>{{ item.price }}</td>
<td>{{ item.subtotal }}</td>
</tr>
{% endfor %}
<tr>
<td colspan="3">
<td colspan="4">
<strong class="{{ totalLabelClass }}">Total:</strong>
</td>
<td>&pound;{{ basketTotal }}</td>
<td>&pound;<span class="ocshop-total">{{ basketTotal }}</span></td>
</tr>
</tbody>
</table>
16 changes: 10 additions & 6 deletions components/product/default.htm
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
<div class="{{ imagesetContainerClass }}">
<div class="{{ rowClass }}">
{% for image in product.images %}
<div class="{{ image.sort_order == '1' ? mainImageContainerClass : subImageContainerClass }}">
{% if image.sort_order == '1' %}
{% set imageContainerClass = mainImageContainerClass %}
{% set imageSize = mainImageSize %}
{% else %}
{% set imageContainerClass = subImageContainerClass %}
{% set imageSize = subImageSize %}
{% endif %}

<div class="{{ imageContainerClass }}">
<a href="{{ image.getPath() }}" class="{{ imageLinkClass }}">
<img class="{{ imageClass }}" alt="{{ product.title }}"
{% if image.sort_order == '1' %}
src="{{ product.getSquareThumb(mainImageSize, image) }}"
{% else %}
src="{{ product.getSquareThumb(subImageSize, image) }}"
{% endif %}
src="{{ product.getSquareThumb(imageSize, image) }}"
/>
</a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "dshoreman/shop",
"description": "",
"description": "Standalone eCommerce plugin for October CMS",
"homepage": "http://dsdev.io/",
"keywords": [],
"keywords": ['october', 'ecommerce', 'shop', 'stripe', 'product', 'plugin'],
"authors": [
{
"name": "Dave Shoreman",
Expand Down

0 comments on commit 73cd792

Please sign in to comment.