Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: adamjudd/FoxyStripe
base: f3990d9c25
...
head fork: adamjudd/FoxyStripe
compare: 3fe9345fc4
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
2  Code/BaseFoxyCartTemplate.php → Code/FoxyCartTemplate.php
@@ -28,7 +28,7 @@ public function init(){
// is there a better way to detect if any kind of jquery is loaded??
// apparently we can tell foxycart we are including jquery as well, but its not available on a fresh install of silverstripe..
- //Requirements::block('themes/current-theme/javascript/jquery-1.6.1.min.js');
+ //Requirements::block('themes/'.SSViewer::current_theme().'/javascript/jquery-1.6.1.min.js');
Requirements::block('sapphire/thirdparty/prototype/prototype.js');
Requirements::block('sapphire/thirdparty/behaviour/behaviour.js');
Requirements::block('sapphire/javascript/prototype_improvements.js');
View
6 Code/ProductHolder.php
@@ -26,5 +26,9 @@ public function getCMSFields(){
}
class ProductHolder_Controller extends Page_Controller {
-
+ public function init(){
+ parent::init();
+ Requirements::css('FoxyStripe/css/foxycart.css');
+ Requirements::customScript("window.jQuery || document.write('<script src=\'//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js\'><\/script>');");
+ }
}
View
57 Code/ProductPage.php
@@ -23,7 +23,13 @@ class ProductPage extends Page {
'ProductImages' => 'ProductImage',
'ProductOptions' => 'OptionItem'
);
-
+ public function populateDefaults(){
+ parent::populateDefaults();
+ if(!$this->Category){
+ $cat = DataObject::get_one('ProductCategory', "`Code`='DEFAULT'");
+ $this->CategoryID = $cat->ID;
+ }
+ }
public function getCMSFields(){
$fields = parent::getCMSFields();
@@ -132,31 +138,36 @@ public function getCMSFields(){
return $fields;
}
- public function onBeforeWrite(){
- if(!$this->Category){
- $cat = DataObject::get_one('ProductCategory', "`Code`='DEFAULT'");
- $this->CategoryID = $cat->ID;
- }
- parent::onBeforeWrite();
- }
-
public function onBeforeDelete(){
- if($this->ProductOptions()) $this->ProductOptions()->delete();
- if($this->ProductImages()) $this->ProductImages()->delete();
- parent::onBeforeDelete();
- }
+ if($this->Status != "Published"){
+ if($this->ProductOptions()){
+ $options = $this->getComponents('ProductOptions');
+ foreach($options as $option){
+ $option->delete();
+ }
+ }
+ if($this->ProductImages()){
+ //delete product image dataobjects, not the images themselves.
+ $images = $this->getComponents('ProductImages');
+ foreach($images as $image){
+ $image->delete();
+ }
+ }
+ }
+ parent::onBeforeDelete();
+ }
- public function getCMSValidator() {
- return new RequiredFields('Price', 'Weight', 'Code');
- }
+ public function getCMSValidator() {
+ return new RequiredFields('Price', 'Weight', 'Code');
+ }
- public function getFormTag(){
- return FoxyCart::FormActionURL();
- }
+ public function getFormTag(){
+ return FoxyCart::FormActionURL();
+ }
- function PurchaseForm(){
- return self::ProductOptionsForm();
- }
+ function PurchaseForm(){
+ return self::ProductOptionsForm();
+ }
function SingleProductForm(){
//make sure to urlencode url params
@@ -328,4 +339,4 @@ public function init(){
Requirements::css('FoxyStripe/css/foxycart.css');
Requirements::customScript("window.jQuery || document.write('<script src=\'//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js\'><\/script>');");
}
-}
+}
View
2  templates/Layout/CheckoutPage.ss
@@ -1,4 +1,4 @@
-<div class="typograpiy contentLayout">
+<div class="typography contentLayout">
$Content
^^cart^^
^^checkout^^

No commit comments for this range

Something went wrong with that request. Please try again.