@@ -55,7 +55,7 @@ |
||
| 55 | 55 | public function requireDefaultRecords() { |
| 56 | 56 | parent::requireDefaultRecords(); |
| 57 | 57 | $allCats = DataObject::get('ProductCategory'); |
| 58 | - if(!$allCats->count()){ |
|
| 58 | + if (!$allCats->count()) { |
|
| 59 | 59 | $cat = new ProductCategory(); |
| 60 | 60 | $cat->Title = 'Default'; |
| 61 | 61 | $cat->Code = 'DEFAULT'; |
@@ -17,9 +17,8 @@ discard block |
||
| 17 | 17 | // handle POST from FoxyCart API transaction |
| 18 | 18 | if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
| 19 | 19 | $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
| 20 | - urldecode($_POST["FoxyData"]) : |
|
| 21 | - urldecode($_POST["FoxySubscriptionData"]); |
|
| 22 | - $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
| 20 | + urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]); |
|
| 21 | + $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(), $FoxyData_encrypted); |
|
| 23 | 22 | self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
| 24 | 23 | |
| 25 | 24 | // extend to allow for additional integrations with Datafeed |
@@ -27,65 +26,63 @@ discard block |
||
| 27 | 26 | |
| 28 | 27 | return 'foxy'; |
| 29 | 28 | |
| 30 | - } else { |
|
| 29 | + }else { |
|
| 31 | 30 | |
| 32 | 31 | return "No FoxyData or FoxySubscriptionData received."; |
| 33 | 32 | |
| 34 | 33 | } |
| 35 | 34 | } |
| 36 | 35 | |
| 37 | - public function handleDataFeed($encrypted, $decrypted){ |
|
| 36 | + public function handleDataFeed($encrypted, $decrypted) { |
|
| 38 | 37 | //handle encrypted & decrypted data |
| 39 | 38 | $orders = new SimpleXMLElement($decrypted); |
| 40 | 39 | |
| 41 | 40 | // loop over each transaction |
| 42 | 41 | foreach ($orders->transactions->transaction as $order) { |
| 43 | 42 | |
| 44 | - if(isset($order->id)) { |
|
| 43 | + if (isset($order->id)) { |
|
| 45 | 44 | ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ? |
| 46 | - $transaction : |
|
| 47 | - $transaction = Order::create(); |
|
| 45 | + $transaction : $transaction = Order::create(); |
|
| 48 | 46 | } |
| 49 | 47 | |
| 50 | 48 | // Record transaction data from FoxyCart Datafeed: |
| 51 | - $transaction->Order_ID = (int) $order->id; |
|
| 52 | - $transaction->Store_ID = (int) $order->store_id; |
|
| 53 | - $transaction->StoreVersion = (string) $order->store_version; |
|
| 54 | - $transaction->IsTest = (int) $order->is_test; |
|
| 55 | - $transaction->IsHidden = (int) $order->is_hidden; |
|
| 56 | - $transaction->DataIsFed = (int) $order->data_is_fed; |
|
| 57 | - $transaction->TransactionDate = (string) $order->transaction_date; |
|
| 58 | - $transaction->ProcessorResponse = (string) $order->processor_response; |
|
| 59 | - $transaction->ShiptoShippingServiceDescription = (string) $order->shipto_shipping_service_description; |
|
| 60 | - $transaction->ProductTotal = (float) $order->product_total; |
|
| 61 | - $transaction->TaxTotal = (float) $order->tax_total; |
|
| 62 | - $transaction->ShippingTotal = (float) $order->shipping_total; |
|
| 63 | - $transaction->OrderTotal = (float) $order->order_total; |
|
| 64 | - $transaction->PaymentGatewayType = (string) $order->payment_gateway_type; |
|
| 65 | - $transaction->ReceiptURL = (string) $order->receipt_url; |
|
| 66 | - $transaction->OrderStatus = (string) $order->status; |
|
| 67 | - $transaction->CustomerIP = (string) $order->customer_ip; |
|
| 49 | + $transaction->Order_ID = (int)$order->id; |
|
| 50 | + $transaction->Store_ID = (int)$order->store_id; |
|
| 51 | + $transaction->StoreVersion = (string)$order->store_version; |
|
| 52 | + $transaction->IsTest = (int)$order->is_test; |
|
| 53 | + $transaction->IsHidden = (int)$order->is_hidden; |
|
| 54 | + $transaction->DataIsFed = (int)$order->data_is_fed; |
|
| 55 | + $transaction->TransactionDate = (string)$order->transaction_date; |
|
| 56 | + $transaction->ProcessorResponse = (string)$order->processor_response; |
|
| 57 | + $transaction->ShiptoShippingServiceDescription = (string)$order->shipto_shipping_service_description; |
|
| 58 | + $transaction->ProductTotal = (float)$order->product_total; |
|
| 59 | + $transaction->TaxTotal = (float)$order->tax_total; |
|
| 60 | + $transaction->ShippingTotal = (float)$order->shipping_total; |
|
| 61 | + $transaction->OrderTotal = (float)$order->order_total; |
|
| 62 | + $transaction->PaymentGatewayType = (string)$order->payment_gateway_type; |
|
| 63 | + $transaction->ReceiptURL = (string)$order->receipt_url; |
|
| 64 | + $transaction->OrderStatus = (string)$order->status; |
|
| 65 | + $transaction->CustomerIP = (string)$order->customer_ip; |
|
| 68 | 66 | $transaction->Response = $decrypted; |
| 69 | 67 | |
| 70 | 68 | // Customer info |
| 71 | 69 | // if not a guest transaction in FoxyCart |
| 72 | - if(isset($order->customer_email) && $order->is_anonymous == 0) { |
|
| 70 | + if (isset($order->customer_email) && $order->is_anonymous == 0) { |
|
| 73 | 71 | |
| 74 | 72 | // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
| 75 | 73 | Config::inst()->update('Security', 'password_encryption_algorithm', 'none'); |
| 76 | 74 | |
| 77 | 75 | // if Customer is existing member, associate with current order |
| 78 | 76 | ($customer = Member::get()->filter('Email', $order->customer_email)->First()) ? |
| 79 | - $customer : |
|
| 80 | - $customer = Member::create(); |
|
| 81 | - |
|
| 82 | - $customer->Customer_ID = (int) $order->customer_id; |
|
| 83 | - $customer->MinifraudScore = (string) $order->minifraud_score; |
|
| 84 | - $customer->FirstName = (string) $order->customer_first_name; |
|
| 85 | - $customer->Surname = (string) $order->customer_last_name; |
|
| 86 | - $customer->Email = (string) $order->customer_email; |
|
| 87 | - $customer->Password = (string) $order->customer_password; |
|
| 88 | - $customer->Salt = (string) $order->customer_password_salt; |
|
| 77 | + $customer : $customer = Member::create(); |
|
| 78 | + |
|
| 79 | + $customer->Customer_ID = (int)$order->customer_id; |
|
| 80 | + $customer->MinifraudScore = (string)$order->minifraud_score; |
|
| 81 | + $customer->FirstName = (string)$order->customer_first_name; |
|
| 82 | + $customer->Surname = (string)$order->customer_last_name; |
|
| 83 | + $customer->Email = (string)$order->customer_email; |
|
| 84 | + $customer->Password = (string)$order->customer_password; |
|
| 85 | + $customer->Salt = (string)$order->customer_password_salt; |
|
| 89 | 86 | $customer->PasswordEncryption = 'none'; |
| 90 | 87 | |
| 91 | 88 | // record member record |
@@ -98,38 +95,36 @@ discard block |
||
| 98 | 95 | |
| 99 | 96 | // billing address |
| 100 | 97 | ($billingAddress = OrderAddress::get()->filter('OrderID', $transaction->Order_ID)->First()) ? |
| 101 | - $billingAddress : |
|
| 102 | - $billingAddress = OrderAddress::create(); |
|
| 103 | - |
|
| 104 | - $billingAddress->Name = $customer->FirstName . ' ' . $customer->Surname; |
|
| 105 | - $billingAddress->Company = (string) $order->customer_company; |
|
| 106 | - $billingAddress->Address1 = (string) $order->customer_address1; |
|
| 107 | - $billingAddress->Address2 = (string) $order->customer_address2; |
|
| 108 | - $billingAddress->City = (string) $order->customer_city; |
|
| 109 | - $billingAddress->State = (string) $order->customer_state; |
|
| 110 | - $billingAddress->PostalCode = (string) $order->customer_postal_code; |
|
| 111 | - $billingAddress->Country = (string) $order->customer_country; |
|
| 112 | - $billingAddress->Phone = (string) $order->customer_phone; |
|
| 113 | - if($customer) $billingAddress->CustomerID = $customer->ID; |
|
| 98 | + $billingAddress : $billingAddress = OrderAddress::create(); |
|
| 99 | + |
|
| 100 | + $billingAddress->Name = $customer->FirstName.' '.$customer->Surname; |
|
| 101 | + $billingAddress->Company = (string)$order->customer_company; |
|
| 102 | + $billingAddress->Address1 = (string)$order->customer_address1; |
|
| 103 | + $billingAddress->Address2 = (string)$order->customer_address2; |
|
| 104 | + $billingAddress->City = (string)$order->customer_city; |
|
| 105 | + $billingAddress->State = (string)$order->customer_state; |
|
| 106 | + $billingAddress->PostalCode = (string)$order->customer_postal_code; |
|
| 107 | + $billingAddress->Country = (string)$order->customer_country; |
|
| 108 | + $billingAddress->Phone = (string)$order->customer_phone; |
|
| 109 | + if ($customer) $billingAddress->CustomerID = $customer->ID; |
|
| 114 | 110 | |
| 115 | 111 | // record billing address |
| 116 | 112 | $billingAddress->write(); |
| 117 | 113 | |
| 118 | 114 | // shipping address |
| 119 | 115 | ($shippingAddress = OrderAddress::get()->filter('OrderID', $transaction->Order_ID)->First()) ? |
| 120 | - $shippingAddress : |
|
| 121 | - $shippingAddress = OrderAddress::create(); |
|
| 122 | - |
|
| 123 | - $shippingAddress->Name = $customer->FirstName . ' ' . $customer->Surname; |
|
| 124 | - $shippingAddress->Company = (string) $order->shipping_company; |
|
| 125 | - $shippingAddress->Address1 = (string) $order->shipping_address1; |
|
| 126 | - $shippingAddress->Address2 = (string) $order->shipping_address2; |
|
| 127 | - $shippingAddress->City = (string) $order->shipping_city; |
|
| 128 | - $shippingAddress->State = (string) $order->shipping_state; |
|
| 129 | - $shippingAddress->PostalCode = (string) $order->shipping_postal_code; |
|
| 130 | - $shippingAddress->Country = (string) $order->shipping_country; |
|
| 131 | - $shippingAddress->Phone = (string) $order->shipping_phone; |
|
| 132 | - if($customer) $shippingAddress->CustomerID = $customer->ID; |
|
| 116 | + $shippingAddress : $shippingAddress = OrderAddress::create(); |
|
| 117 | + |
|
| 118 | + $shippingAddress->Name = $customer->FirstName.' '.$customer->Surname; |
|
| 119 | + $shippingAddress->Company = (string)$order->shipping_company; |
|
| 120 | + $shippingAddress->Address1 = (string)$order->shipping_address1; |
|
| 121 | + $shippingAddress->Address2 = (string)$order->shipping_address2; |
|
| 122 | + $shippingAddress->City = (string)$order->shipping_city; |
|
| 123 | + $shippingAddress->State = (string)$order->shipping_state; |
|
| 124 | + $shippingAddress->PostalCode = (string)$order->shipping_postal_code; |
|
| 125 | + $shippingAddress->Country = (string)$order->shipping_country; |
|
| 126 | + $shippingAddress->Phone = (string)$order->shipping_phone; |
|
| 127 | + if ($customer) $shippingAddress->CustomerID = $customer->ID; |
|
| 133 | 128 | |
| 134 | 129 | // record shipping address |
| 135 | 130 | $shippingAddress->write(); |
@@ -152,17 +147,17 @@ discard block |
||
| 152 | 147 | $ProductOption = OrderDetail::create(); |
| 153 | 148 | |
| 154 | 149 | // set Quantity |
| 155 | - $ProductOption->Quantity = (int) $product->product_quantity; |
|
| 150 | + $ProductOption->Quantity = (int)$product->product_quantity; |
|
| 156 | 151 | |
| 157 | 152 | // set calculated price (after option modifiers) |
| 158 | - $ProductOption->Price = (float) $product->product_price; |
|
| 153 | + $ProductOption->Price = (float)$product->product_price; |
|
| 159 | 154 | |
| 160 | 155 | // Find product via product_id custom variable |
| 161 | 156 | foreach ($product->transaction_detail_options->transaction_detail_option as $productID) { |
| 162 | 157 | if ($productID->product_option_name == 'product_id') { |
| 163 | 158 | |
| 164 | 159 | $OrderProduct = ProductPage::get() |
| 165 | - ->filter('ID', (int) $productID->product_option_value) |
|
| 160 | + ->filter('ID', (int)$productID->product_option_value) |
|
| 166 | 161 | ->First(); |
| 167 | 162 | |
| 168 | 163 | // if product could be found, then set Option Items |
@@ -175,15 +170,15 @@ discard block |
||
| 175 | 170 | foreach ($product->transaction_detail_options->transaction_detail_option as $option) { |
| 176 | 171 | |
| 177 | 172 | $OptionItem = OptionItem::get()->filter(array( |
| 178 | - 'ProductID' => (string) $OrderProduct->ID, |
|
| 179 | - 'Title' => (string) $option->product_option_value |
|
| 173 | + 'ProductID' => (string)$OrderProduct->ID, |
|
| 174 | + 'Title' => (string)$option->product_option_value |
|
| 180 | 175 | ))->First(); |
| 181 | 176 | |
| 182 | 177 | if ($OptionItem) { |
| 183 | 178 | $ProductOption->Options()->add($OptionItem); |
| 184 | 179 | |
| 185 | 180 | // modify product price |
| 186 | - if($priceMod = $option->price_mod) { |
|
| 181 | + if ($priceMod = $option->price_mod) { |
|
| 187 | 182 | $ProductOption->Price += $priceMod; |
| 188 | 183 | } |
| 189 | 184 | } |
@@ -215,17 +210,17 @@ discard block |
||
| 215 | 210 | // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
| 216 | 211 | // fake user will redirect to FC checkout, ask customer to log in |
| 217 | 212 | // to do: consider a login/registration form here if not logged in |
| 218 | - if($Member = Member::currentUser()) { |
|
| 213 | + if ($Member = Member::currentUser()) { |
|
| 219 | 214 | $Member = Member::currentUser(); |
| 220 | - } else { |
|
| 215 | + }else { |
|
| 221 | 216 | $Member = new Member(); |
| 222 | 217 | $Member->Customer_ID = 0; |
| 223 | 218 | } |
| 224 | 219 | |
| 225 | - $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
| 220 | + $auth_token = sha1($Member->Customer_ID.'|'.$timestampNew.'|'.FoxyCart::getStoreKey()); |
|
| 226 | 221 | |
| 227 | - $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . |
|
| 228 | - '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
|
| 222 | + $redirect_complete = 'https://'.FoxyCart::getFoxyCartStoreName().'.foxycart.com/checkout?fc_auth_token='.$auth_token. |
|
| 223 | + '&fcsid='.$fcsid.'&fc_customer_id='.$Member->Customer_ID.'×tamp='.$timestampNew; |
|
| 229 | 224 | |
| 230 | 225 | $this->redirect($redirect_complete); |
| 231 | 226 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | private static $plural_name = 'Order History Pages'; |
| 12 | 12 | private static $description = 'Show a customers past orders. Requires authentication'; |
| 13 | 13 | |
| 14 | - public function getCMSFields(){ |
|
| 14 | + public function getCMSFields() { |
|
| 15 | 15 | $fields = parent::getCMSFields(); |
| 16 | 16 | |
| 17 | 17 | |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | public function checkMember() { |
| 44 | - if(Member::currentUser()) { |
|
| 44 | + if (Member::currentUser()) { |
|
| 45 | 45 | return true; |
| 46 | - } else { |
|
| 47 | - return Security::permissionFailure ($this, _t ( |
|
| 46 | + }else { |
|
| 47 | + return Security::permissionFailure($this, _t( |
|
| 48 | 48 | 'AccountPage.CANNOTCONFIRMLOGGEDIN', |
| 49 | 49 | 'Please login to view this page.' |
| 50 | 50 | )); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $previewDescription = ($this->stat('customPreviewDescription')) ? $this->stat('customPreviewDescription') : _t('ProductPage.PreviewImageDescription', 'Image used throughout site to represent this product'); |
| 88 | 88 | |
| 89 | 89 | // Cateogry Dropdown field w/ add new |
| 90 | - $source = function(){ |
|
| 90 | + $source = function() { |
|
| 91 | 91 | return ProductCategory::get()->map()->toArray(); |
| 92 | 92 | }; |
| 93 | 93 | $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source()) |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | // Product Options field |
| 123 | 123 | $config = GridFieldConfig_RelationEditor::create(); |
| 124 | 124 | if (class_exists('GridFieldBulkManager')) $config->addComponent(new GridFieldBulkManager()); |
| 125 | - if (class_exists('GridFieldSortableRows')){ |
|
| 125 | + if (class_exists('GridFieldSortableRows')) { |
|
| 126 | 126 | $config->addComponent(new GridFieldSortableRows('SortOrder')); |
| 127 | 127 | $products = $this->ProductOptions()->sort('SortOrder'); |
| 128 | - }else{ |
|
| 128 | + }else { |
|
| 129 | 129 | $products = $this->ProductOptions(); |
| 130 | 130 | } |
| 131 | 131 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | ->setFolderName('Uploads/Products') |
| 182 | 182 | ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')) |
| 183 | 183 | ->setAllowedMaxFileNumber(1), |
| 184 | - HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD'. 'Product Image Gallery'), 2), |
|
| 184 | + HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD'.'Product Image Gallery'), 2), |
|
| 185 | 185 | $prodImagesField |
| 186 | 186 | ->setDescription(_t( |
| 187 | 187 | 'ProductPage.ProductImagesDescription', |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | $prodOptField |
| 201 | 201 | )); |
| 202 | 202 | |
| 203 | - if(!$this->DiscountTitle && $this->ProductDiscountTiers()->exists()){ |
|
| 203 | + if (!$this->DiscountTitle && $this->ProductDiscountTiers()->exists()) { |
|
| 204 | 204 | $fields->addFieldTotab('Root.Discounts', new LiteralField("ProductDiscountHeaderWarning", "<p class=\"message warning\">A discount title is required for FoxyCart to properly parse the value. The discounts will not be applied until a title is entered.</p>")); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $fields->addFieldToTab('Root.Discounts', TextField::create('DiscountTitle')->setTitle(_t('Product.DiscountTitle','Discount Title'))); |
|
| 207 | + $fields->addFieldToTab('Root.Discounts', TextField::create('DiscountTitle')->setTitle(_t('Product.DiscountTitle', 'Discount Title'))); |
|
| 208 | 208 | $discountsConfig = GridFieldConfig_RelationEditor::create(); |
| 209 | 209 | $discountsConfig->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
| 210 | 210 | $discountsConfig->removeComponentsByType('GridFieldDeleteAction'); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $discountGrid = GridField::create('ProductDiscountTiers', 'Product Discounts', $this->ProductDiscountTiers(), $discountsConfig); |
| 213 | 213 | $fields->addFieldToTab('Root.Discounts', $discountGrid); |
| 214 | 214 | |
| 215 | - if(FoxyCart::store_name_warning()!==null){ |
|
| 215 | + if (FoxyCart::store_name_warning() !== null) { |
|
| 216 | 216 | $fields->addFieldToTab('Root.Main', LiteralField::create("StoreSubDomainHeaderWarning", _t( |
| 217 | 217 | 'ProductPage.StoreSubDomainHeaderWarning', |
| 218 | 218 | "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
@@ -225,25 +225,25 @@ discard block |
||
| 225 | 225 | return $fields; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - public function onBeforeWrite(){ |
|
| 228 | + public function onBeforeWrite() { |
|
| 229 | 229 | parent::onBeforeWrite(); |
| 230 | - if(!$this->CategoryID){ |
|
| 230 | + if (!$this->CategoryID) { |
|
| 231 | 231 | $default = ProductCategory::get()->filter(array('Code' => 'DEFAULT'))->first(); |
| 232 | 232 | $this->CategoryID = $default->ID; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | //update many_many lists when multi-group is on |
| 236 | - if(SiteConfig::current_site_config()->MultiGroup){ |
|
| 236 | + if (SiteConfig::current_site_config()->MultiGroup) { |
|
| 237 | 237 | $holders = $this->ProductHolders(); |
| 238 | 238 | $product = ProductPage::get()->byID($this->ID); |
| 239 | 239 | if (isset($product->ParentID)) { |
| 240 | 240 | $origParent = $product->ParentID; |
| 241 | - } else { |
|
| 241 | + }else { |
|
| 242 | 242 | $origParent = null; |
| 243 | 243 | } |
| 244 | 244 | $currentParent = $this->ParentID; |
| 245 | - if($origParent!=$currentParent){ |
|
| 246 | - if($holders->find('ID', $origParent)){ |
|
| 245 | + if ($origParent != $currentParent) { |
|
| 246 | + if ($holders->find('ID', $origParent)) { |
|
| 247 | 247 | $holders->removeByID($origParent); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - public function onAfterWrite(){ |
|
| 261 | + public function onAfterWrite() { |
|
| 262 | 262 | parent::onAfterWrite(); |
| 263 | 263 | |
| 264 | 264 | |
@@ -266,17 +266,17 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | public function onBeforeDelete() { |
| 269 | - if(!$this->isPublished()) { |
|
| 269 | + if (!$this->isPublished()) { |
|
| 270 | 270 | |
| 271 | - $delete = function($object){ |
|
| 271 | + $delete = function($object) { |
|
| 272 | 272 | $object->delete(); |
| 273 | 273 | }; |
| 274 | 274 | |
| 275 | - if($this->ProductOptions()) { |
|
| 275 | + if ($this->ProductOptions()) { |
|
| 276 | 276 | $options = $this->getComponents('ProductOptions'); |
| 277 | 277 | $options->each($delete); |
| 278 | 278 | } |
| 279 | - if($this->ProductImages()) { |
|
| 279 | + if ($this->ProductImages()) { |
|
| 280 | 280 | //delete product image dataobjects, not the images themselves. |
| 281 | 281 | $images = $this->getComponents('ProductImages'); |
| 282 | 282 | $images->each($delete); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | parent::onBeforeDelete(); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - public function validate(){ |
|
| 289 | + public function validate() { |
|
| 290 | 290 | $result = parent::validate(); |
| 291 | 291 | |
| 292 | 292 | /*if($this->ID>0){ |
@@ -308,17 +308,16 @@ discard block |
||
| 308 | 308 | return new RequiredFields(array('CategoryID', 'Price', 'Weight', 'Code')); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - public static function getGeneratedValue($productCode = null, $optionName = null, $optionValue = null, $method = 'name', $output = false, $urlEncode = false){ |
|
| 312 | - $optionName = ($optionName !== null) ? preg_replace('/\s/','_', $optionName) : $optionName; |
|
| 311 | + public static function getGeneratedValue($productCode = null, $optionName = null, $optionValue = null, $method = 'name', $output = false, $urlEncode = false) { |
|
| 312 | + $optionName = ($optionName !== null) ? preg_replace('/\s/', '_', $optionName) : $optionName; |
|
| 313 | 313 | return (SiteConfig::current_site_config()->CartValidation) |
| 314 | - ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode): |
|
| 315 | - $optionValue; |
|
| 314 | + ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) : $optionValue; |
|
| 316 | 315 | } |
| 317 | 316 | |
| 318 | - public function getDiscountFieldValue(){ |
|
| 317 | + public function getDiscountFieldValue() { |
|
| 319 | 318 | $tiers = $this->ProductDiscountTiers(); |
| 320 | 319 | $bulkString = ''; |
| 321 | - foreach($tiers as $tier){ |
|
| 320 | + foreach ($tiers as $tier) { |
|
| 322 | 321 | $bulkString .= "|{$tier->Quantity}-{$tier->Percentage}"; |
| 323 | 322 | } |
| 324 | 323 | return "{$this->Title}{allunits{$bulkString}}"; |
@@ -340,7 +339,7 @@ discard block |
||
| 340 | 339 | return Permission::check('Product_CANCRUD'); |
| 341 | 340 | } |
| 342 | 341 | |
| 343 | - public function canPublish($member = null){ |
|
| 342 | + public function canPublish($member = null) { |
|
| 344 | 343 | return Permission::check('Product_CANCRUD'); |
| 345 | 344 | } |
| 346 | 345 | |
@@ -358,10 +357,10 @@ discard block |
||
| 358 | 357 | 'PurchaseForm' |
| 359 | 358 | ); |
| 360 | 359 | |
| 361 | - public function init(){ |
|
| 360 | + public function init() { |
|
| 362 | 361 | parent::init(); |
| 363 | 362 | Requirements::javascript("framework/thirdparty/jquery/jquery.js"); |
| 364 | - if($this->data()->Available && $this->ProductOptions()->exists()){ |
|
| 363 | + if ($this->data()->Available && $this->ProductOptions()->exists()) { |
|
| 365 | 364 | Requirements::javascript("foxystripe/javascript/outOfStock.min.js"); |
| 366 | 365 | Requirements::javascript("foxystripe/javascript/ProductOptions.min.js"); |
| 367 | 366 | } |
@@ -376,7 +375,7 @@ discard block |
||
| 376 | 375 | |
| 377 | 376 | $config = SiteConfig::current_site_config(); |
| 378 | 377 | |
| 379 | - $assignAvailable = function($self){ |
|
| 378 | + $assignAvailable = function($self) { |
|
| 380 | 379 | $self->Available = ($self->getAvailability()) ? true : false; |
| 381 | 380 | }; |
| 382 | 381 | |
@@ -386,12 +385,12 @@ discard block |
||
| 386 | 385 | $hiddenTitle = ($data->ReceiptTitle) ? htmlspecialchars($data->ReceiptTitle) : htmlspecialchars($data->Title); |
| 387 | 386 | $code = $data->Code; |
| 388 | 387 | |
| 389 | - if($data->Available) { |
|
| 388 | + if ($data->Available) { |
|
| 390 | 389 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'name', $hiddenTitle))->setValue($hiddenTitle)); |
| 391 | 390 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'category', $data->Category()->Code))->setValue($data->Category()->Code)); |
| 392 | 391 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'code', $data->Code))->setValue($data->Code)); |
| 393 | 392 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'product_id', $data->ID))->setValue($data->ID)); |
| 394 | - $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'price', $data->Price))->setValue($data->Price));//can't override id |
|
| 393 | + $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'price', $data->Price))->setValue($data->Price)); //can't override id |
|
| 395 | 394 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'weight', $data->Weight))->setValue($data->Weight)); |
| 396 | 395 | if ($this->DiscountTitle && $this->ProductDiscountTiers()->exists()) { |
| 397 | 396 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'discount_quantity_percentage', $data->getDiscountFieldValue()))->setValue($data->getDiscountFieldValue())); |
@@ -407,16 +406,16 @@ discard block |
||
| 407 | 406 | |
| 408 | 407 | $optionsSet = CompositeField::create(); |
| 409 | 408 | |
| 410 | - foreach($groupedBy as $id => $set){ |
|
| 409 | + foreach ($groupedBy as $id => $set) { |
|
| 411 | 410 | $group = OptionGroup::get()->byID($id); |
| 412 | 411 | $title = $group->Title; |
| 413 | - $name = preg_replace('/\s/','_', $title); |
|
| 412 | + $name = preg_replace('/\s/', '_', $title); |
|
| 414 | 413 | $set->each($assignAvailable); |
| 415 | 414 | $disabled = array(); |
| 416 | 415 | $fullOptions = array(); |
| 417 | - foreach($set as $item){ |
|
| 416 | + foreach ($set as $item) { |
|
| 418 | 417 | $fullOptions[ProductPage::getGeneratedValue($data->Code, $group->Title, $item->getGeneratedValue(), 'value')] = $item->getGeneratedTitle(); |
| 419 | - if(!$item->Availability) array_push($disabled, ProductPage::getGeneratedValue($data->Code, $group->Title, $item->getGeneratedValue(), 'value')); |
|
| 418 | + if (!$item->Availability) array_push($disabled, ProductPage::getGeneratedValue($data->Code, $group->Title, $item->getGeneratedValue(), 'value')); |
|
| 420 | 419 | } |
| 421 | 420 | $optionsSet->push( |
| 422 | 421 | $dropdown = DropdownField::create($name, $title, $fullOptions)->setTitle($title) |
@@ -438,7 +437,7 @@ discard block |
||
| 438 | 437 | |
| 439 | 438 | $fields->push(DropdownField::create('quantity', 'Quantity', $quantity)); |
| 440 | 439 | |
| 441 | - $fields->push(HeaderField::create('submitPrice', '$' . $data->Price, 4)); |
|
| 440 | + $fields->push(HeaderField::create('submitPrice', '$'.$data->Price, 4)); |
|
| 442 | 441 | |
| 443 | 442 | |
| 444 | 443 | $actions = FieldList::create( |
@@ -448,17 +447,17 @@ discard block |
||
| 448 | 447 | ) |
| 449 | 448 | ); |
| 450 | 449 | $submit->setAttribute('name', ProductPage::getGeneratedValue($code, 'Submit', _t('ProductForm.AddToCart', 'Add to Cart'))); |
| 451 | - if(!$config->StoreName || $config->StoreName == '' || !isset($config->StoreName)){ |
|
| 450 | + if (!$config->StoreName || $config->StoreName == '' || !isset($config->StoreName)) { |
|
| 452 | 451 | $submit->setAttribute('Disabled', true); |
| 453 | 452 | } |
| 454 | 453 | $this->extend('updatePurchaseFormFields', $fields); |
| 455 | - }else{ |
|
| 454 | + }else { |
|
| 456 | 455 | $fields->push(HeaderField::create('submitPrice', 'Currently Out of Stock'), 4); |
| 457 | 456 | $actions = FieldList::create(); |
| 458 | 457 | } |
| 459 | 458 | |
| 460 | 459 | $form = Form::create($this, 'PurchaseForm', $fields, $actions); |
| 461 | - $form->setAttribute('action',FoxyCart::FormActionURL()); |
|
| 460 | + $form->setAttribute('action', FoxyCart::FormActionURL()); |
|
| 462 | 461 | $form->disableSecurityToken(); |
| 463 | 462 | |
| 464 | 463 | $this->extend('updatePurchaseForm', $form); |
@@ -35,20 +35,20 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | - public function getCMSFields(){ |
|
| 38 | + public function getCMSFields() { |
|
| 39 | 39 | $fields = parent::getCMSFields(); |
| 40 | 40 | |
| 41 | - if(SiteConfig::current_site_config()->MultiGroup){ |
|
| 41 | + if (SiteConfig::current_site_config()->MultiGroup) { |
|
| 42 | 42 | |
| 43 | 43 | $config = GridFieldConfig_RelationEditor::create(); |
| 44 | - if(class_exists('GridFieldManyRelationHandler')){ |
|
| 44 | + if (class_exists('GridFieldManyRelationHandler')) { |
|
| 45 | 45 | $config->addComponent(new GridFieldManyRelationHandler(), 'GridFieldPaginator'); |
| 46 | - if(class_exists('GridFieldSortableRows')) { |
|
| 46 | + if (class_exists('GridFieldSortableRows')) { |
|
| 47 | 47 | $config->addComponent(new GridFieldSortableRows("SortOrder"), 'GridFieldManyRelationHandler'); |
| 48 | 48 | } |
| 49 | 49 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
| 50 | - }else{ |
|
| 51 | - if(class_exists('GridFieldSortableRows')) $config->addComponent(new GridFieldSortableRows("SortOrder")); |
|
| 50 | + }else { |
|
| 51 | + if (class_exists('GridFieldSortableRows')) $config->addComponent(new GridFieldSortableRows("SortOrder")); |
|
| 52 | 52 | } |
| 53 | 53 | $config->removeComponentsByType($config->getComponentByType('GridFieldAddNewButton')); |
| 54 | 54 | |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function loadDescendantProductGroupIDListInto(&$idList) { |
| 85 | 85 | if ($children = $this->AllChildren()) { |
| 86 | - foreach($children as $child) { |
|
| 87 | - if(in_array($child->ID, $idList)) continue; |
|
| 86 | + foreach ($children as $child) { |
|
| 87 | + if (in_array($child->ID, $idList)) continue; |
|
| 88 | 88 | |
| 89 | - if($child instanceof ProductHolder) { |
|
| 89 | + if ($child instanceof ProductHolder) { |
|
| 90 | 90 | $idList[] = $child->ID; |
| 91 | 91 | $child->loadDescendantProductGroupIDListInto($idList); |
| 92 | 92 | } |
@@ -116,23 +116,23 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $config = SiteConfig::current_site_config(); |
| 118 | 118 | |
| 119 | - if($config->ProductLimit>0){ |
|
| 119 | + if ($config->ProductLimit > 0) { |
|
| 120 | 120 | $limit = $config->ProductLimit; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if($config->MultiGroup){ |
|
| 123 | + if ($config->MultiGroup) { |
|
| 124 | 124 | $entries = $this->Products()->sort('SortOrder'); |
| 125 | - }else{ |
|
| 126 | - $filter = '"ParentID" = ' . $this->ID; |
|
| 125 | + }else { |
|
| 126 | + $filter = '"ParentID" = '.$this->ID; |
|
| 127 | 127 | |
| 128 | 128 | // Build a list of all IDs for ProductGroups that are children |
| 129 | 129 | $holderIDs = $this->ProductGroupIDs(); |
| 130 | 130 | |
| 131 | 131 | // If no ProductHolders, no ProductPages. So return false |
| 132 | - if($holderIDs) { |
|
| 132 | + if ($holderIDs) { |
|
| 133 | 133 | // Otherwise, do the actual query |
| 134 | - if($filter) $filter .= ' OR '; |
|
| 135 | - $filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ")"; |
|
| 134 | + if ($filter) $filter .= ' OR '; |
|
| 135 | + $filter .= '"ParentID" IN ('.implode(',', $holderIDs).")"; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $order = '"SiteTree"."Title" ASC'; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | class ProductHolder_Controller extends Page_Controller { |
| 152 | 152 | |
| 153 | - public function init(){ |
|
| 153 | + public function init() { |
|
| 154 | 154 | parent::init(); |
| 155 | 155 | |
| 156 | 156 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class FoxyStripeSiteConfig extends DataExtension{ |
|
| 3 | +class FoxyStripeSiteConfig extends DataExtension { |
|
| 4 | 4 | |
| 5 | 5 | private static $db = array( |
| 6 | 6 | 'StoreName' => 'Varchar(255)', |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | 'ProductLimit' => 10 |
| 17 | 17 | ); |
| 18 | 18 | |
| 19 | - public function updateCMSFields(FieldList $fields){ |
|
| 19 | + public function updateCMSFields(FieldList $fields) { |
|
| 20 | 20 | |
| 21 | 21 | // set TabSet names to avoid spaces from camel case |
| 22 | 22 | $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | )); |
| 56 | 56 | |
| 57 | 57 | // configuration warning |
| 58 | - if(FoxyCart::store_name_warning()!==null){ |
|
| 58 | + if (FoxyCart::store_name_warning() !== null) { |
|
| 59 | 59 | $fields->insertBefore(LiteralField::create( |
| 60 | 60 | "StoreSubDomainHeaderWarning", |
| 61 | 61 | _t( |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $siteConfig = SiteConfig::current_site_config(); |
| 139 | 139 | |
| 140 | - if(!$siteConfig->StoreKey) { |
|
| 140 | + if (!$siteConfig->StoreKey) { |
|
| 141 | 141 | $key = FoxyCart::setStoreKey(); |
| 142 | - while(!ctype_alnum($key)){ |
|
| 142 | + while (!ctype_alnum($key)) { |
|
| 143 | 143 | $key = FoxyCart::setStoreKey(); |
| 144 | 144 | } |
| 145 | 145 | $siteConfig->StoreKey = $key; |
| 146 | 146 | $siteConfig->write(); |
| 147 | - DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key " . $key, 'created'); |
|
| 147 | + DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key ".$key, 'created'); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | // get FoxyCart Store Name for JS call |
| 6 | 6 | public function getCartScript() { |
| 7 | - return '<script src="https://cdn.foxycart.com/' . FoxyCart::getFoxyCartStoreName() . '/loader.js" async defer></script>'; |
|
| 7 | + return '<script src="https://cdn.foxycart.com/'.FoxyCart::getFoxyCartStoreName().'/loader.js" async defer></script>'; |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | } |
| 11 | 11 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class CustomerExtension extends DataExtension{ |
|
| 3 | +class CustomerExtension extends DataExtension { |
|
| 4 | 4 | |
| 5 | 5 | private static $db = array( |
| 6 | 6 | 'Customer_ID' => 'Int', |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | $response = FoxyCart::putCustomer($this->owner); |
| 28 | 28 | |
| 29 | 29 | // Grab customer_id record from FoxyCart response, store in Member |
| 30 | - if($response){ |
|
| 30 | + if ($response) { |
|
| 31 | 31 | $foxyResponse = new SimpleXMLElement($response); |
| 32 | - $this->owner->Customer_ID = (int) $foxyResponse->customer_id; |
|
| 32 | + $this->owner->Customer_ID = (int)$foxyResponse->customer_id; |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |