Skip to content

Instantly share code, notes, and snippets.

View jedateach's full-sized avatar
🤓

Jeremy Shipman jedateach

🤓
View GitHub Profile
@jedateach
jedateach / Pagination.ss
Last active December 22, 2015 03:08
Reuse your pagination template!!!
<% if $Me.MoreThanOnePage %>
<div class="pagination">
<a href="$FirstLink" class="pagination_first">First</a>
<% loop $Me.PaginationSummary %>
<% if $CurrentBool %>
<span class="pagination_num pagination_current">$PageNum</span>
<% else %>
<% if $Link %>
<a class="pagination_num" href="$Link">$PageNum</a>
<% else %>
@jedateach
jedateach / Order.php
Last active December 16, 2015 11:59
getting an OrderItemList, instaed of HasManyList
<?php
//in Order class
public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = null) {
$components = parent::getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = null);
if($componentName === "Items" && get_class($components) !== "UnsavedRelationList"){
$query = $components->dataQuery();
$components = new OrderItemList("OrderItem", "OrderID");
if($this->model) $components->setDataModel($this->model);
@jedateach
jedateach / ProductVariationsFiltering.php
Created April 19, 2013 02:03
Draft code for filtering product variations on the front-end
<?php
if((isset($_SESSION['FilterTypes'])) && $types = $_SESSION['FilterTypes']){
$products = $products->innerJoin("ProductVariation","PV.ProductID = Product_Live.ID","PV");
$y = 0;
foreach ($types as $type){
$products = $products->innerJoin("ProductVariation_AttributeValues","PVA".$y.".ProductVariationID = PV.ID","PVA".$y);
$wheres = array();
foreach ($type as $value){
$wheres[] = "PVA".$y.".ProductAttributeValueID = ".$value;
@jedateach
jedateach / CreateOrder.php
Last active December 16, 2015 08:59
Shop rewrite prototyping (created around march 2012)
<?php
/**
* Playing with how one might go about creating an order via Class/Object calls.
*
* @see http://inchoo.net/ecommerce/magento/programmatically-create-order-in-magento/
*
*/
$order = new Order();
@jedateach
jedateach / Address.php
Last active December 16, 2015 08:58
Initial ideas for address autocomplete
<?php
/*
* Provides a way to create, store and render addresses.
*
* Updates to addresses will cause a new address to be created, if it has been used in the past. Otherwise the existing address is updated.
*
*/
class Address extends DataObject{
@jedateach
jedateach / ShopApi.php
Created April 18, 2013 01:54
Shop API planning
<?php
class Address_handler{
static $allowed_actions = array('GET','POST');
function GET($request){
}
@jedateach
jedateach / DummyTest.php
Created December 4, 2012 04:06
Slow Tests in SilverStripe 3
<?php
class DummyTest extends SapphireTest{
function testNothing(){
}
}
@jedateach
jedateach / templates_Content_MyPage.ss
Created July 22, 2012 22:55
Using Content as a template placeholder in SilverStripe
The actual content to show up. Can also put $Content here to have DB field included.
@jedateach
jedateach / MyForm.php
Created July 20, 2012 02:29
Custom form field to model field mapping.
<?php
class MyForm extends Form{
/**
* Override saveInto to allow custom form field to model field mapping.
*/
function saveInto($dataObject,$fieldList = null){
$this->mapFieldNames($fieldList);
parent::saveInto($dataObject,$fieldList);
@jedateach
jedateach / RegionShippingModifier.php
Created July 4, 2012 04:32
Region Shipping Modifier
<?php
class RegionShippingModifier extends OrderModifier{
//TODO: allow defining regions / prices with databobjects in SiteConfig
static $db = array(
'Region' => 'Varchar'
);