@@ -10,15 +10,15 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | static $allowed_actions = array( |
| 12 | 12 | 'index', |
| 13 | - 'sso' |
|
| 13 | + 'sso' |
|
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | 16 | public function index() { |
| 17 | - // handle POST from FoxyCart API transaction |
|
| 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"]); |
|
| 20 | + urldecode($_POST["FoxyData"]) : |
|
| 21 | + urldecode($_POST["FoxySubscriptionData"]); |
|
| 22 | 22 | $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
| 23 | 23 | self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
| 24 | 24 | |
@@ -35,200 +35,200 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function handleDataFeed($encrypted, $decrypted){ |
| 38 | - //handle encrypted & decrypted data |
|
| 39 | - $orders = new SimpleXMLElement($decrypted); |
|
| 38 | + //handle encrypted & decrypted data |
|
| 39 | + $orders = new SimpleXMLElement($decrypted); |
|
| 40 | 40 | |
| 41 | 41 | // loop over each transaction |
| 42 | - foreach ($orders->transactions->transaction as $order) { |
|
| 43 | - |
|
| 44 | - if(isset($order->id)) { |
|
| 45 | - ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ? |
|
| 46 | - $transaction : |
|
| 47 | - $transaction = Order::create(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // 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; |
|
| 68 | - $transaction->Response = $decrypted; |
|
| 69 | - |
|
| 70 | - // Customer info |
|
| 71 | - // if not a guest transaction in FoxyCart |
|
| 72 | - if(isset($order->customer_email) && $order->is_anonymous == 0) { |
|
| 73 | - |
|
| 74 | - // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
|
| 75 | - Config::inst()->update('Security', 'password_encryption_algorithm', 'none'); |
|
| 76 | - |
|
| 77 | - // if Customer is existing member, associate with current order |
|
| 78 | - ($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; |
|
| 89 | - $customer->PasswordEncryption = 'none'; |
|
| 90 | - |
|
| 91 | - // record member record |
|
| 92 | - $customer->write(); |
|
| 42 | + foreach ($orders->transactions->transaction as $order) { |
|
| 43 | + |
|
| 44 | + if(isset($order->id)) { |
|
| 45 | + ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ? |
|
| 46 | + $transaction : |
|
| 47 | + $transaction = Order::create(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // 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; |
|
| 68 | + $transaction->Response = $decrypted; |
|
| 69 | + |
|
| 70 | + // Customer info |
|
| 71 | + // if not a guest transaction in FoxyCart |
|
| 72 | + if(isset($order->customer_email) && $order->is_anonymous == 0) { |
|
| 73 | + |
|
| 74 | + // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
|
| 75 | + Config::inst()->update('Security', 'password_encryption_algorithm', 'none'); |
|
| 76 | + |
|
| 77 | + // if Customer is existing member, associate with current order |
|
| 78 | + ($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; |
|
| 89 | + $customer->PasswordEncryption = 'none'; |
|
| 90 | + |
|
| 91 | + // record member record |
|
| 92 | + $customer->write(); |
|
| 93 | 93 | |
| 94 | - // set Order MemberID |
|
| 95 | - $transaction->MemberID = $customer->ID; |
|
| 94 | + // set Order MemberID |
|
| 95 | + $transaction->MemberID = $customer->ID; |
|
| 96 | 96 | |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | // billing address |
| 100 | 100 | ($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; |
|
| 114 | - |
|
| 115 | - // record billing address |
|
| 116 | - $billingAddress->write(); |
|
| 117 | - |
|
| 118 | - // shipping address |
|
| 119 | - ($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; |
|
| 133 | - |
|
| 134 | - // record shipping address |
|
| 135 | - $shippingAddress->write(); |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - // Associate with Order |
|
| 139 | - $transaction->BillingAddressID = $billingAddress->ID; |
|
| 140 | - $transaction->ShippingAddressID = $shippingAddress->ID; |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - // record transaction as order |
|
| 144 | - $transaction->write(); |
|
| 145 | - |
|
| 146 | - // remove previous $many_many Options so we don't end up with duplicates |
|
| 147 | - $transaction->Details()->removeAll(); |
|
| 148 | - |
|
| 149 | - // Associate ProductPages, Options, Quanity with Order |
|
| 150 | - foreach ($order->transaction_details->transaction_detail as $product) { |
|
| 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; |
|
| 114 | + |
|
| 115 | + // record billing address |
|
| 116 | + $billingAddress->write(); |
|
| 117 | + |
|
| 118 | + // shipping address |
|
| 119 | + ($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; |
|
| 133 | + |
|
| 134 | + // record shipping address |
|
| 135 | + $shippingAddress->write(); |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + // Associate with Order |
|
| 139 | + $transaction->BillingAddressID = $billingAddress->ID; |
|
| 140 | + $transaction->ShippingAddressID = $shippingAddress->ID; |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + // record transaction as order |
|
| 144 | + $transaction->write(); |
|
| 145 | + |
|
| 146 | + // remove previous $many_many Options so we don't end up with duplicates |
|
| 147 | + $transaction->Details()->removeAll(); |
|
| 148 | + |
|
| 149 | + // Associate ProductPages, Options, Quanity with Order |
|
| 150 | + foreach ($order->transaction_details->transaction_detail as $product) { |
|
| 151 | 151 | |
| 152 | - $ProductOption = OrderDetail::create(); |
|
| 152 | + $ProductOption = OrderDetail::create(); |
|
| 153 | 153 | |
| 154 | - // set Quantity |
|
| 155 | - $ProductOption->Quantity = (int) $product->product_quantity; |
|
| 154 | + // set Quantity |
|
| 155 | + $ProductOption->Quantity = (int) $product->product_quantity; |
|
| 156 | 156 | |
| 157 | - // set calculated price (after option modifiers) |
|
| 158 | - $ProductOption->Price = (float) $product->product_price; |
|
| 157 | + // set calculated price (after option modifiers) |
|
| 158 | + $ProductOption->Price = (float) $product->product_price; |
|
| 159 | 159 | |
| 160 | - // Find product via product_id custom variable |
|
| 161 | - foreach ($product->transaction_detail_options->transaction_detail_option as $productID) { |
|
| 162 | - if ($productID->product_option_name == 'product_id') { |
|
| 160 | + // Find product via product_id custom variable |
|
| 161 | + foreach ($product->transaction_detail_options->transaction_detail_option as $productID) { |
|
| 162 | + if ($productID->product_option_name == 'product_id') { |
|
| 163 | 163 | |
| 164 | - $OrderProduct = ProductPage::get() |
|
| 165 | - ->filter('ID', (int) $productID->product_option_value) |
|
| 166 | - ->First(); |
|
| 164 | + $OrderProduct = ProductPage::get() |
|
| 165 | + ->filter('ID', (int) $productID->product_option_value) |
|
| 166 | + ->First(); |
|
| 167 | 167 | |
| 168 | 168 | // if product could be found, then set Option Items |
| 169 | - if ($OrderProduct) { |
|
| 169 | + if ($OrderProduct) { |
|
| 170 | 170 | |
| 171 | - // set Product |
|
| 172 | - $ProductOption->ProductID = $OrderProduct->ID; |
|
| 171 | + // set Product |
|
| 172 | + $ProductOption->ProductID = $OrderProduct->ID; |
|
| 173 | 173 | |
| 174 | - // loop through all Product Options |
|
| 175 | - foreach ($product->transaction_detail_options->transaction_detail_option as $option) { |
|
| 174 | + // loop through all Product Options |
|
| 175 | + foreach ($product->transaction_detail_options->transaction_detail_option as $option) { |
|
| 176 | 176 | |
| 177 | - $OptionItem = OptionItem::get()->filter(array( |
|
| 178 | - 'ProductID' => (string) $OrderProduct->ID, |
|
| 179 | - 'Title' => (string) $option->product_option_value |
|
| 180 | - ))->First(); |
|
| 177 | + $OptionItem = OptionItem::get()->filter(array( |
|
| 178 | + 'ProductID' => (string) $OrderProduct->ID, |
|
| 179 | + 'Title' => (string) $option->product_option_value |
|
| 180 | + ))->First(); |
|
| 181 | 181 | |
| 182 | - if ($OptionItem) { |
|
| 183 | - $ProductOption->Options()->add($OptionItem); |
|
| 182 | + if ($OptionItem) { |
|
| 183 | + $ProductOption->Options()->add($OptionItem); |
|
| 184 | 184 | |
| 185 | - // modify product price |
|
| 186 | - if($priceMod = $option->price_mod) { |
|
| 187 | - $ProductOption->Price += $priceMod; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - // associate with this order |
|
| 195 | - $ProductOption->OrderID = $transaction->ID; |
|
| 185 | + // modify product price |
|
| 186 | + if($priceMod = $option->price_mod) { |
|
| 187 | + $ProductOption->Price += $priceMod; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + // associate with this order |
|
| 195 | + $ProductOption->OrderID = $transaction->ID; |
|
| 196 | 196 | |
| 197 | - // extend OrderDetail parsing, allowing for recording custom fields in FoxyCart |
|
| 197 | + // extend OrderDetail parsing, allowing for recording custom fields in FoxyCart |
|
| 198 | 198 | $this->extend('handleOrderItem', $decrypted, $product, $ProductOption); |
| 199 | 199 | |
| 200 | 200 | // write |
| 201 | - $ProductOption->write(); |
|
| 201 | + $ProductOption->write(); |
|
| 202 | 202 | |
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Single Sign on integration with FoxyCart |
| 209 | - public function sso() { |
|
| 210 | - |
|
| 211 | - // GET variables from FoxyCart Request |
|
| 212 | - $fcsid = $this->request->getVar('fcsid'); |
|
| 213 | - $timestampNew = strtotime('+30 days'); |
|
| 214 | - |
|
| 215 | - // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
|
| 216 | - // fake user will redirect to FC checkout, ask customer to log in |
|
| 217 | - // to do: consider a login/registration form here if not logged in |
|
| 218 | - if($Member = Member::currentUser()) { |
|
| 219 | - $Member = Member::currentUser(); |
|
| 220 | - } else { |
|
| 221 | - $Member = new Member(); |
|
| 222 | - $Member->Customer_ID = 0; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
| 226 | - |
|
| 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; |
|
| 209 | + public function sso() { |
|
| 210 | + |
|
| 211 | + // GET variables from FoxyCart Request |
|
| 212 | + $fcsid = $this->request->getVar('fcsid'); |
|
| 213 | + $timestampNew = strtotime('+30 days'); |
|
| 214 | + |
|
| 215 | + // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
|
| 216 | + // fake user will redirect to FC checkout, ask customer to log in |
|
| 217 | + // to do: consider a login/registration form here if not logged in |
|
| 218 | + if($Member = Member::currentUser()) { |
|
| 219 | + $Member = Member::currentUser(); |
|
| 220 | + } else { |
|
| 221 | + $Member = new Member(); |
|
| 222 | + $Member->Customer_ID = 0; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
| 226 | + |
|
| 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; |
|
| 229 | 229 | |
| 230 | - $this->redirect($redirect_complete); |
|
| 230 | + $this->redirect($redirect_complete); |
|
| 231 | 231 | |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | } |
| 235 | 235 | \ No newline at end of file |
@@ -7,9 +7,9 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class OrderHistoryPage extends Page { |
| 9 | 9 | |
| 10 | - private static $singular_name = 'Order History Page'; |
|
| 11 | - private static $plural_name = 'Order History Pages'; |
|
| 12 | - private static $description = 'Show a customers past orders. Requires authentication'; |
|
| 10 | + private static $singular_name = 'Order History Page'; |
|
| 11 | + private static $plural_name = 'Order History Pages'; |
|
| 12 | + private static $description = 'Show a customers past orders. Requires authentication'; |
|
| 13 | 13 | |
| 14 | 14 | public function getCMSFields(){ |
| 15 | 15 | $fields = parent::getCMSFields(); |
@@ -20,43 +20,43 @@ discard block |
||
| 20 | 20 | return $fields; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - // return all current Member's Orders |
|
| 24 | - public function getOrders($limit = 10) { |
|
| 25 | - if ($Member = Member::currentUser()) { |
|
| 26 | - $Orders = $Member->Orders()->sort('TransactionDate', 'DESC'); |
|
| 23 | + // return all current Member's Orders |
|
| 24 | + public function getOrders($limit = 10) { |
|
| 25 | + if ($Member = Member::currentUser()) { |
|
| 26 | + $Orders = $Member->Orders()->sort('TransactionDate', 'DESC'); |
|
| 27 | 27 | |
| 28 | - $list = new PaginatedList($Orders, Controller::curr()->request); |
|
| 29 | - $list->setPageLength($limit); |
|
| 30 | - return $list; |
|
| 31 | - } |
|
| 32 | - return false; |
|
| 33 | - } |
|
| 28 | + $list = new PaginatedList($Orders, Controller::curr()->request); |
|
| 29 | + $list->setPageLength($limit); |
|
| 30 | + return $list; |
|
| 31 | + } |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | class OrderHistoryPage_Controller extends Page_Controller { |
| 38 | 38 | |
| 39 | 39 | private static $allowed_actions = array( |
| 40 | - 'index' |
|
| 41 | - ); |
|
| 42 | - |
|
| 43 | - public function checkMember() { |
|
| 44 | - if(Member::currentUser()) { |
|
| 45 | - return true; |
|
| 46 | - } else { |
|
| 47 | - return Security::permissionFailure ($this, _t ( |
|
| 48 | - 'AccountPage.CANNOTCONFIRMLOGGEDIN', |
|
| 49 | - 'Please login to view this page.' |
|
| 50 | - )); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function Index() { |
|
| 55 | - |
|
| 56 | - $this->checkMember(); |
|
| 57 | - return array(); |
|
| 58 | - |
|
| 59 | - } |
|
| 40 | + 'index' |
|
| 41 | + ); |
|
| 42 | + |
|
| 43 | + public function checkMember() { |
|
| 44 | + if(Member::currentUser()) { |
|
| 45 | + return true; |
|
| 46 | + } else { |
|
| 47 | + return Security::permissionFailure ($this, _t ( |
|
| 48 | + 'AccountPage.CANNOTCONFIRMLOGGEDIN', |
|
| 49 | + 'Please login to view this page.' |
|
| 50 | + )); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function Index() { |
|
| 55 | + |
|
| 56 | + $this->checkMember(); |
|
| 57 | + return array(); |
|
| 58 | + |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | } |
| 63 | 63 | \ No newline at end of file |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | class ProductPage extends Page implements PermissionProvider { |
| 9 | 9 | |
| 10 | 10 | private static $allowed_children = 'none'; |
| 11 | - private static $default_parent = 'ProductHolder'; |
|
| 12 | - private static $can_be_root = false; |
|
| 11 | + private static $default_parent = 'ProductHolder'; |
|
| 12 | + private static $can_be_root = false; |
|
| 13 | 13 | |
| 14 | 14 | private static $db = array( |
| 15 | 15 | 'Price' => 'Currency', |
@@ -29,72 +29,72 @@ discard block |
||
| 29 | 29 | private static $has_many = array( |
| 30 | 30 | 'ProductImages' => 'ProductImage', |
| 31 | 31 | 'ProductOptions' => 'OptionItem', |
| 32 | - 'OrderDetails' => 'OrderDetail', |
|
| 32 | + 'OrderDetails' => 'OrderDetail', |
|
| 33 | 33 | 'ProductDiscountTiers' => 'ProductDiscountTier' |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - private static $belongs_many_many = array( |
|
| 36 | + private static $belongs_many_many = array( |
|
| 37 | 37 | 'ProductHolders' => 'ProductHolder' |
| 38 | - ); |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - private static $singular_name = 'Product'; |
|
| 41 | - private static $plural_name = 'Products'; |
|
| 42 | - private static $description = 'A product that can be added to the shopping cart'; |
|
| 40 | + private static $singular_name = 'Product'; |
|
| 41 | + private static $plural_name = 'Products'; |
|
| 42 | + private static $description = 'A product that can be added to the shopping cart'; |
|
| 43 | 43 | |
| 44 | - private static $indexes = array( |
|
| 45 | - 'Code' => true // make unique |
|
| 46 | - ); |
|
| 44 | + private static $indexes = array( |
|
| 45 | + 'Code' => true // make unique |
|
| 46 | + ); |
|
| 47 | 47 | |
| 48 | 48 | private static $defaults = array( |
| 49 | 49 | 'ShowInMenus' => false, |
| 50 | 50 | 'Available' => true, |
| 51 | - 'Weight' => '1.0' |
|
| 51 | + 'Weight' => '1.0' |
|
| 52 | + ); |
|
| 53 | + |
|
| 54 | + private static $summary_fields = array( |
|
| 55 | + 'Title', |
|
| 56 | + 'Code', |
|
| 57 | + 'Price.Nice', |
|
| 58 | + 'Category.Title' |
|
| 52 | 59 | ); |
| 53 | 60 | |
| 54 | - private static $summary_fields = array( |
|
| 55 | - 'Title', |
|
| 56 | - 'Code', |
|
| 57 | - 'Price.Nice', |
|
| 58 | - 'Category.Title' |
|
| 59 | - ); |
|
| 60 | - |
|
| 61 | - private static $searchable_fields = array( |
|
| 62 | - 'Title', |
|
| 63 | - 'Code', |
|
| 64 | - 'Featured', |
|
| 65 | - 'Available', |
|
| 66 | - 'Category.ID' |
|
| 67 | - ); |
|
| 68 | - |
|
| 69 | - function fieldLabels($includerelations = true) { |
|
| 70 | - $labels = parent::fieldLabels(); |
|
| 71 | - |
|
| 72 | - $labels['Title'] = _t('ProductPage.TitleLabel', 'Name'); |
|
| 73 | - $labels['Code'] = _t('ProductPage.CodeLabel', "Code"); |
|
| 74 | - $labels['Price.Nice'] = _t('ProductPage.PriceLabel', 'Price'); |
|
| 75 | - $labels['Featured.Nice'] = _t('ProductPage.NiceLabel', 'Featured'); |
|
| 76 | - $labels['Available.Nice'] = _t('ProductPage.AvailableLabel', 'Available'); |
|
| 77 | - $labels['Category.ID'] = _t('ProductPage.IDLabel', 'Category'); |
|
| 78 | - $labels['Category.Title'] = _t('ProductPage.CategoryTitleLabel', 'Category'); |
|
| 79 | - |
|
| 80 | - return $labels; |
|
| 81 | - } |
|
| 61 | + private static $searchable_fields = array( |
|
| 62 | + 'Title', |
|
| 63 | + 'Code', |
|
| 64 | + 'Featured', |
|
| 65 | + 'Available', |
|
| 66 | + 'Category.ID' |
|
| 67 | + ); |
|
| 68 | + |
|
| 69 | + function fieldLabels($includerelations = true) { |
|
| 70 | + $labels = parent::fieldLabels(); |
|
| 71 | + |
|
| 72 | + $labels['Title'] = _t('ProductPage.TitleLabel', 'Name'); |
|
| 73 | + $labels['Code'] = _t('ProductPage.CodeLabel', "Code"); |
|
| 74 | + $labels['Price.Nice'] = _t('ProductPage.PriceLabel', 'Price'); |
|
| 75 | + $labels['Featured.Nice'] = _t('ProductPage.NiceLabel', 'Featured'); |
|
| 76 | + $labels['Available.Nice'] = _t('ProductPage.AvailableLabel', 'Available'); |
|
| 77 | + $labels['Category.ID'] = _t('ProductPage.IDLabel', 'Category'); |
|
| 78 | + $labels['Category.Title'] = _t('ProductPage.CategoryTitleLabel', 'Category'); |
|
| 79 | + |
|
| 80 | + return $labels; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | public function getCMSFields() { |
| 84 | 84 | $fields = parent::getCMSFields(); |
| 85 | 85 | |
| 86 | - // allow extensions of ProductPage to override the PreviewImage field description |
|
| 86 | + // allow extensions of ProductPage to override the PreviewImage field description |
|
| 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 | 90 | $source = function(){ |
| 91 | - return ProductCategory::get()->map()->toArray(); |
|
| 91 | + return ProductCategory::get()->map()->toArray(); |
|
| 92 | 92 | }; |
| 93 | 93 | $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source()) |
| 94 | - ->setEmptyString('') |
|
| 95 | - ->setDescription(_t( |
|
| 96 | - 'ProductPage.CategoryDescription', |
|
| 97 | - 'Required, must also exist in |
|
| 94 | + ->setEmptyString('') |
|
| 95 | + ->setDescription(_t( |
|
| 96 | + 'ProductPage.CategoryDescription', |
|
| 97 | + 'Required, must also exist in |
|
| 98 | 98 | <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank"> |
| 99 | 99 | FoxyCart Categories |
| 100 | 100 | </a>. |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | <a href="admin/settings"> |
| 103 | 103 | Settings > FoxyStripe > Categories |
| 104 | 104 | </a>' |
| 105 | - )); |
|
| 105 | + )); |
|
| 106 | 106 | if (class_exists('QuickAddNewExtension')) $catField->useAddNew('ProductCategory', $source); |
| 107 | 107 | |
| 108 | 108 | // Product Images gridfield |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | $config->getComponentByType('GridFieldBulkUpload')->setUfConfig('folderName', 'Uploads/ProductImages'); |
| 114 | 114 | } |
| 115 | 115 | $prodImagesField = GridField::create( |
| 116 | - 'ProductImages', |
|
| 117 | - _t('ProductPage.ProductImages', 'Images'), |
|
| 118 | - $this->ProductImages(), |
|
| 119 | - $config |
|
| 120 | - ); |
|
| 116 | + 'ProductImages', |
|
| 117 | + _t('ProductPage.ProductImages', 'Images'), |
|
| 118 | + $this->ProductImages(), |
|
| 119 | + $config |
|
| 120 | + ); |
|
| 121 | 121 | |
| 122 | 122 | // Product Options field |
| 123 | 123 | $config = GridFieldConfig_RelationEditor::create(); |
@@ -130,47 +130,47 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
| 132 | 132 | $prodOptField = GridField::create( |
| 133 | - 'ProductOptions', |
|
| 134 | - _t('ProductPage.ProductOptions', 'Options'), |
|
| 135 | - $products, |
|
| 136 | - $config |
|
| 137 | - ); |
|
| 133 | + 'ProductOptions', |
|
| 134 | + _t('ProductPage.ProductOptions', 'Options'), |
|
| 135 | + $products, |
|
| 136 | + $config |
|
| 137 | + ); |
|
| 138 | 138 | |
| 139 | 139 | // Details tab |
| 140 | 140 | $fields->addFieldsToTab('Root.Details', array( |
| 141 | 141 | HeaderField::create('DetailHD', 'Product Details', 2), |
| 142 | 142 | CheckboxField::create('Available') |
| 143 | 143 | ->setTitle(_t('ProductPage.Available', 'Available for purchase')) |
| 144 | - ->setDescription(_t( |
|
| 145 | - 'ProductPage.AvailableDescription', |
|
| 146 | - 'If unchecked, will remove "Add to Cart" form and instead display "Currently unavailable"' |
|
| 147 | - )), |
|
| 148 | - TextField::create('Code') |
|
| 149 | - ->setTitle(_t('ProductPage.Code', 'Product Code')) |
|
| 150 | - ->setDescription(_t( |
|
| 151 | - 'ProductPage.CodeDescription', |
|
| 152 | - 'Required, must be unique. Product identifier used by FoxyCart in transactions' |
|
| 153 | - )), |
|
| 154 | - $catField, |
|
| 155 | - CurrencyField::create('Price') |
|
| 156 | - ->setTitle(_t('ProductPage.Price', 'Price')) |
|
| 157 | - ->setDescription(_t( |
|
| 158 | - 'ProductPage.PriceDescription', |
|
| 159 | - 'Base price for this product. Can be modified using Product Options' |
|
| 160 | - )), |
|
| 161 | - NumericField::create('Weight') |
|
| 162 | - ->setTitle(_t('ProductPage.Weight', 'Weight')) |
|
| 163 | - ->setDescription(_t( |
|
| 164 | - 'ProductPage.WeightDescription', |
|
| 165 | - 'Base weight for this product in lbs. Can be modified using Product Options' |
|
| 166 | - )), |
|
| 144 | + ->setDescription(_t( |
|
| 145 | + 'ProductPage.AvailableDescription', |
|
| 146 | + 'If unchecked, will remove "Add to Cart" form and instead display "Currently unavailable"' |
|
| 147 | + )), |
|
| 148 | + TextField::create('Code') |
|
| 149 | + ->setTitle(_t('ProductPage.Code', 'Product Code')) |
|
| 150 | + ->setDescription(_t( |
|
| 151 | + 'ProductPage.CodeDescription', |
|
| 152 | + 'Required, must be unique. Product identifier used by FoxyCart in transactions' |
|
| 153 | + )), |
|
| 154 | + $catField, |
|
| 155 | + CurrencyField::create('Price') |
|
| 156 | + ->setTitle(_t('ProductPage.Price', 'Price')) |
|
| 157 | + ->setDescription(_t( |
|
| 158 | + 'ProductPage.PriceDescription', |
|
| 159 | + 'Base price for this product. Can be modified using Product Options' |
|
| 160 | + )), |
|
| 161 | + NumericField::create('Weight') |
|
| 162 | + ->setTitle(_t('ProductPage.Weight', 'Weight')) |
|
| 163 | + ->setDescription(_t( |
|
| 164 | + 'ProductPage.WeightDescription', |
|
| 165 | + 'Base weight for this product in lbs. Can be modified using Product Options' |
|
| 166 | + )), |
|
| 167 | 167 | CheckboxField::create('Featured') |
| 168 | 168 | ->setTitle(_t('ProductPage.Featured', 'Featured Product')), |
| 169 | - TextField::create('ReceiptTitle') |
|
| 170 | - ->setTitle(_t('ProductPage.ReceiptTitle', 'Product Title for Receipt')) |
|
| 171 | - ->setDescription(_t( |
|
| 172 | - 'ProductPage.ReceiptTitleDescription', 'Optional' |
|
| 173 | - )) |
|
| 169 | + TextField::create('ReceiptTitle') |
|
| 170 | + ->setTitle(_t('ProductPage.ReceiptTitle', 'Product Title for Receipt')) |
|
| 171 | + ->setDescription(_t( |
|
| 172 | + 'ProductPage.ReceiptTitleDescription', 'Optional' |
|
| 173 | + )) |
|
| 174 | 174 | )); |
| 175 | 175 | |
| 176 | 176 | // Images tab |
@@ -184,19 +184,19 @@ discard block |
||
| 184 | 184 | HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD'. 'Product Image Gallery'), 2), |
| 185 | 185 | $prodImagesField |
| 186 | 186 | ->setDescription(_t( |
| 187 | - 'ProductPage.ProductImagesDescription', |
|
| 188 | - 'Additional Product Images, shown in gallery on Product page' |
|
| 189 | - )) |
|
| 187 | + 'ProductPage.ProductImagesDescription', |
|
| 188 | + 'Additional Product Images, shown in gallery on Product page' |
|
| 189 | + )) |
|
| 190 | 190 | )); |
| 191 | 191 | |
| 192 | 192 | // Options Tab |
| 193 | 193 | $fields->addFieldsToTab('Root.Options', array( |
| 194 | 194 | HeaderField::create('OptionsHD', _t('ProductPage.OptionsHD', 'Product Options'), 2), |
| 195 | 195 | LiteralField::create('OptionsDescrip', _t( |
| 196 | - 'Page.OptionsDescrip', |
|
| 197 | - '<p>Product Options allow products to be customized by attributes such as size or color. |
|
| 196 | + 'Page.OptionsDescrip', |
|
| 197 | + '<p>Product Options allow products to be customized by attributes such as size or color. |
|
| 198 | 198 | Options can also modify the product\'s price, weight or code.</p>' |
| 199 | - )), |
|
| 199 | + )), |
|
| 200 | 200 | $prodOptField |
| 201 | 201 | )); |
| 202 | 202 | |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | if(FoxyCart::store_name_warning()!==null){ |
| 216 | 216 | $fields->addFieldToTab('Root.Main', LiteralField::create("StoreSubDomainHeaderWarning", _t( |
| 217 | - 'ProductPage.StoreSubDomainHeaderWarning', |
|
| 218 | - "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
|
| 219 | - )), 'Title'); |
|
| 217 | + 'ProductPage.StoreSubDomainHeaderWarning', |
|
| 218 | + "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
|
| 219 | + )), 'Title'); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // allows CMS fields to be extended |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | ) |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - private static $singular_name = 'Product Group'; |
|
| 31 | - private static $plural_name = 'Product Groups'; |
|
| 32 | - private static $description = 'Display a list of related products'; |
|
| 30 | + private static $singular_name = 'Product Group'; |
|
| 31 | + private static $plural_name = 'Product Groups'; |
|
| 32 | + private static $description = 'Display a list of related products'; |
|
| 33 | 33 | |
| 34 | 34 | private static $defaults = array( |
| 35 | 35 | |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
| 144 | - $list = new PaginatedList($entries, Controller::curr()->request); |
|
| 145 | - $list->setPageLength($limit); |
|
| 146 | - return $list; |
|
| 144 | + $list = new PaginatedList($entries, Controller::curr()->request); |
|
| 145 | + $list->setPageLength($limit); |
|
| 146 | + return $list; |
|
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -11,24 +11,24 @@ discard block |
||
| 11 | 11 | 'MaxQuantity' => 'Int' |
| 12 | 12 | ); |
| 13 | 13 | |
| 14 | - // Set Default values |
|
| 15 | - private static $defaults = array( |
|
| 16 | - 'ProductLimit' => 10 |
|
| 17 | - ); |
|
| 14 | + // Set Default values |
|
| 15 | + private static $defaults = array( |
|
| 16 | + 'ProductLimit' => 10 |
|
| 17 | + ); |
|
| 18 | 18 | |
| 19 | 19 | public function updateCMSFields(FieldList $fields){ |
| 20 | 20 | |
| 21 | - // set TabSet names to avoid spaces from camel case |
|
| 22 | - $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
|
| 21 | + // set TabSet names to avoid spaces from camel case |
|
| 22 | + $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
|
| 23 | 23 | |
| 24 | - // settings tab |
|
| 25 | - $fields->addFieldsToTab('Root.FoxyStripe.Settings', array( |
|
| 26 | - // Store Details |
|
| 24 | + // settings tab |
|
| 25 | + $fields->addFieldsToTab('Root.FoxyStripe.Settings', array( |
|
| 26 | + // Store Details |
|
| 27 | 27 | HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), |
| 28 | 28 | LiteralField::create('DetailsIntro', _t( |
| 29 | 29 | 'FoxyStripeSiteConfig.DetailsIntro', |
| 30 | - '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.' |
|
| 31 | - )), |
|
| 30 | + '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.' |
|
| 31 | + )), |
|
| 32 | 32 | TextField::create('StoreName') |
| 33 | 33 | ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Sub Domain')) |
| 34 | 34 | ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'the sub domain for your FoxyCart store')), |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | // Advanced Settings |
| 37 | 37 | HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3), |
| 38 | 38 | LiteralField::create('AdvancedIntro', _t( |
| 39 | - 'FoxyStripeSiteConfig.AdvancedIntro', |
|
| 39 | + 'FoxyStripeSiteConfig.AdvancedIntro', |
|
| 40 | 40 | '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures" target="_blank">FoxyCart advanced store settings</a>.</p>' |
| 41 | 41 | )), |
| 42 | 42 | ReadonlyField::create('DataFeedLink', _t('FoxyStripeSiteConfig.DataFeedLink', 'FoxyCart DataFeed URL'), self::getDataFeedLink()) |
@@ -44,108 +44,108 @@ discard block |
||
| 44 | 44 | CheckboxField::create('CartValidation') |
| 45 | 45 | ->setTitle(_t('FoxyStripeSiteConfig.CartValidation', 'Enable Cart Validation')) |
| 46 | 46 | ->setDescription(_t( |
| 47 | - 'FoxyStripeSiteConfig.CartValidationDescription', |
|
| 48 | - 'You must <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures#use_cart_validation" target="_blank">enable cart validation</a> in the FoxyCart admin.' |
|
| 49 | - )), |
|
| 47 | + 'FoxyStripeSiteConfig.CartValidationDescription', |
|
| 48 | + 'You must <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures#use_cart_validation" target="_blank">enable cart validation</a> in the FoxyCart admin.' |
|
| 49 | + )), |
|
| 50 | 50 | ReadonlyField::create('StoreKey') |
| 51 | 51 | ->setTitle(_t('FoxyStripeSiteConfig.StoreKey', 'FoxyCart API Key')) |
| 52 | 52 | ->setDescription(_t('FoxyStripeSiteConfig.StoreKeyDescription', 'copy/paste to FoxyCart')), |
| 53 | 53 | ReadonlyField::create('SSOLink', _t('FoxyStripeSiteConfig.SSOLink', 'Single Sign On URL'), self::getSSOLink()) |
| 54 | 54 | ->setDescription(_t('FoxyStripeSiteConfig.SSOLinkDescription', 'copy/paste to FoxyCart')) |
| 55 | - )); |
|
| 55 | + )); |
|
| 56 | 56 | |
| 57 | - // configuration warning |
|
| 57 | + // configuration warning |
|
| 58 | 58 | if(FoxyCart::store_name_warning()!==null){ |
| 59 | 59 | $fields->insertBefore(LiteralField::create( |
| 60 | - "StoreSubDomainHeaderWarning", |
|
| 61 | - _t( |
|
| 62 | - 'FoxyStripeSiteConfig.StoreSubDomainHeadingWarning', |
|
| 63 | - "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
|
| 64 | - ) |
|
| 65 | - ), 'StoreDetails'); |
|
| 60 | + "StoreSubDomainHeaderWarning", |
|
| 61 | + _t( |
|
| 62 | + 'FoxyStripeSiteConfig.StoreSubDomainHeadingWarning', |
|
| 63 | + "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
|
| 64 | + ) |
|
| 65 | + ), 'StoreDetails'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - // products tab |
|
| 68 | + // products tab |
|
| 69 | 69 | $fields->addFieldsToTab('Root.FoxyStripe.Products', array( |
| 70 | 70 | HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), |
| 71 | 71 | CheckboxField::create('MultiGroup') |
| 72 | 72 | ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups')) |
| 73 | 73 | ->setDescription(_t( |
| 74 | - 'FoxyStripeSiteConfig.MultiGroupDescription', |
|
| 75 | - 'Allows products to be shown in multiple Product Groups' |
|
| 76 | - )), |
|
| 74 | + 'FoxyStripeSiteConfig.MultiGroupDescription', |
|
| 75 | + 'Allows products to be shown in multiple Product Groups' |
|
| 76 | + )), |
|
| 77 | 77 | HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), |
| 78 | 78 | NumericField::create('ProductLimit') |
| 79 | 79 | ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page')) |
| 80 | 80 | ->setDescription(_t( |
| 81 | - 'FoxyStripeSiteConfig.ProductLimitDescription', |
|
| 82 | - 'Number of Products to show per page on a Product Group' |
|
| 83 | - )), |
|
| 81 | + 'FoxyStripeSiteConfig.ProductLimitDescription', |
|
| 82 | + 'Number of Products to show per page on a Product Group' |
|
| 83 | + )), |
|
| 84 | 84 | HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), |
| 85 | 85 | NumericField::create('MaxQuantity') |
| 86 | 86 | ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity')) |
| 87 | 87 | ->setDescription(_t( |
| 88 | - 'FoxyStripeSiteConfig.MaxQuantityDescription', |
|
| 89 | - 'Sets max quantity for product form dropdown (add to cart form - default 10)' |
|
| 90 | - )) |
|
| 88 | + 'FoxyStripeSiteConfig.MaxQuantityDescription', |
|
| 89 | + 'Sets max quantity for product form dropdown (add to cart form - default 10)' |
|
| 90 | + )) |
|
| 91 | 91 | )); |
| 92 | 92 | |
| 93 | - // categories tab |
|
| 93 | + // categories tab |
|
| 94 | 94 | $fields->addFieldsToTab('Root.FoxyStripe.Categories', array( |
| 95 | 95 | HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), |
| 96 | 96 | LiteralField::create('CategoryDescrip', _t( |
| 97 | - 'FoxyStripeSiteConfig.CategoryDescrip', |
|
| 98 | - '<p>FoxyCart Categories offer a way to give products additional behaviors that cannot be accomplished by product options alone, including category specific coupon codes, shipping and handling fees, and email receipts. <a href="https://wiki.foxycart.com/v/2.0/categories" target="_blank">Learn More</a></p><p>Categories you\'ve created in FoxyStripe must also be created in your <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">FoxyCart Categories</a> admin panel.</p>' |
|
| 99 | - )), |
|
| 97 | + 'FoxyStripeSiteConfig.CategoryDescrip', |
|
| 98 | + '<p>FoxyCart Categories offer a way to give products additional behaviors that cannot be accomplished by product options alone, including category specific coupon codes, shipping and handling fees, and email receipts. <a href="https://wiki.foxycart.com/v/2.0/categories" target="_blank">Learn More</a></p><p>Categories you\'ve created in FoxyStripe must also be created in your <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">FoxyCart Categories</a> admin panel.</p>' |
|
| 99 | + )), |
|
| 100 | 100 | GridField::create( |
| 101 | - 'ProductCategory', |
|
| 102 | - _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'), |
|
| 103 | - ProductCategory::get(), |
|
| 104 | - GridFieldConfig_RecordEditor::create() |
|
| 105 | - ) |
|
| 101 | + 'ProductCategory', |
|
| 102 | + _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'), |
|
| 103 | + ProductCategory::get(), |
|
| 104 | + GridFieldConfig_RecordEditor::create() |
|
| 105 | + ) |
|
| 106 | 106 | )); |
| 107 | 107 | |
| 108 | - // option groups tab |
|
| 108 | + // option groups tab |
|
| 109 | 109 | $fields->addFieldsToTab('Root.FoxyStripe.Groups', array( |
| 110 | 110 | HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), |
| 111 | 111 | LiteralField::create('OptionGroupsDescrip', _t( |
| 112 | - 'FoxyStripeSiteConfig.OptionGroupsDescrip', |
|
| 113 | - '<p>Product Option Groups allow you to name a set of product options.</p>' |
|
| 114 | - )), |
|
| 112 | + 'FoxyStripeSiteConfig.OptionGroupsDescrip', |
|
| 113 | + '<p>Product Option Groups allow you to name a set of product options.</p>' |
|
| 114 | + )), |
|
| 115 | 115 | GridField::create( |
| 116 | - 'OptionGroup', |
|
| 117 | - _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'), |
|
| 118 | - OptionGroup::get(), |
|
| 119 | - GridFieldConfig_RecordEditor::create() |
|
| 120 | - ) |
|
| 116 | + 'OptionGroup', |
|
| 117 | + _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'), |
|
| 118 | + OptionGroup::get(), |
|
| 119 | + GridFieldConfig_RecordEditor::create() |
|
| 120 | + ) |
|
| 121 | 121 | )); |
| 122 | 122 | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - private static function getSSOLink() { |
|
| 126 | - return Director::absoluteBaseURL()."foxystripe/sso/"; |
|
| 127 | - } |
|
| 125 | + private static function getSSOLink() { |
|
| 126 | + return Director::absoluteBaseURL()."foxystripe/sso/"; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - private static function getDataFeedLink() { |
|
| 130 | - return Director::absoluteBaseURL()."foxystripe/"; |
|
| 131 | - } |
|
| 129 | + private static function getDataFeedLink() { |
|
| 130 | + return Director::absoluteBaseURL()."foxystripe/"; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - // generate key on install |
|
| 134 | - public function requireDefaultRecords() { |
|
| 133 | + // generate key on install |
|
| 134 | + public function requireDefaultRecords() { |
|
| 135 | 135 | |
| 136 | - parent::requireDefaultRecords(); |
|
| 136 | + parent::requireDefaultRecords(); |
|
| 137 | 137 | |
| 138 | - $siteConfig = SiteConfig::current_site_config(); |
|
| 138 | + $siteConfig = SiteConfig::current_site_config(); |
|
| 139 | 139 | |
| 140 | - if(!$siteConfig->StoreKey) { |
|
| 141 | - $key = FoxyCart::setStoreKey(); |
|
| 142 | - while(!ctype_alnum($key)){ |
|
| 143 | - $key = FoxyCart::setStoreKey(); |
|
| 144 | - } |
|
| 145 | - $siteConfig->StoreKey = $key; |
|
| 146 | - $siteConfig->write(); |
|
| 147 | - DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key " . $key, 'created'); |
|
| 148 | - } |
|
| 149 | - } |
|
| 140 | + if(!$siteConfig->StoreKey) { |
|
| 141 | + $key = FoxyCart::setStoreKey(); |
|
| 142 | + while(!ctype_alnum($key)){ |
|
| 143 | + $key = FoxyCart::setStoreKey(); |
|
| 144 | + } |
|
| 145 | + $siteConfig->StoreKey = $key; |
|
| 146 | + $siteConfig->write(); |
|
| 147 | + DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key " . $key, 'created'); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | 151 | } |
@@ -2,9 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | class FoxyStripePageExtension extends DataExtension { |
| 4 | 4 | |
| 5 | - // get FoxyCart Store Name for JS call |
|
| 6 | - public function getCartScript() { |
|
| 7 | - return '<script src="https://cdn.foxycart.com/' . FoxyCart::getFoxyCartStoreName() . '/loader.js" async defer></script>'; |
|
| 8 | - } |
|
| 5 | + // get FoxyCart Store Name for JS call |
|
| 6 | + public function getCartScript() { |
|
| 7 | + return '<script src="https://cdn.foxycart.com/' . FoxyCart::getFoxyCartStoreName() . '/loader.js" async defer></script>'; |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | 10 | } |
| 11 | 11 | \ No newline at end of file |
@@ -2,35 +2,35 @@ |
||
| 2 | 2 | |
| 3 | 3 | class CustomerExtension extends DataExtension{ |
| 4 | 4 | |
| 5 | - private static $db = array( |
|
| 6 | - 'Customer_ID' => 'Int', |
|
| 7 | - 'MinifraudScore' => 'Varchar' |
|
| 8 | - ); |
|
| 5 | + private static $db = array( |
|
| 6 | + 'Customer_ID' => 'Int', |
|
| 7 | + 'MinifraudScore' => 'Varchar' |
|
| 8 | + ); |
|
| 9 | 9 | |
| 10 | - private static $has_many = array( |
|
| 11 | - 'Orders' => 'Order', |
|
| 12 | - 'OrderAddresses' => 'OrderAddress' |
|
| 13 | - ); |
|
| 10 | + private static $has_many = array( |
|
| 11 | + 'Orders' => 'Order', |
|
| 12 | + 'OrderAddresses' => 'OrderAddress' |
|
| 13 | + ); |
|
| 14 | 14 | |
| 15 | - private static $indexes = array( |
|
| 16 | - 'Customer_ID' => true // make unique |
|
| 17 | - ); |
|
| 15 | + private static $indexes = array( |
|
| 16 | + 'Customer_ID' => true // make unique |
|
| 17 | + ); |
|
| 18 | 18 | |
| 19 | - public function onBeforeWrite() { |
|
| 20 | - parent::onBeforeWrite(); |
|
| 19 | + public function onBeforeWrite() { |
|
| 20 | + parent::onBeforeWrite(); |
|
| 21 | 21 | |
| 22 | - // if Member data was imported from FoxyCart, PasswordEncryption will be set to 'none'. |
|
| 23 | - // Change to sh1_v2.4 to ensure SilverStripe is using the same hash as FoxyCart API 1.1 |
|
| 24 | - $this->owner->PasswordEncryption = 'sha1_v2.4'; |
|
| 22 | + // if Member data was imported from FoxyCart, PasswordEncryption will be set to 'none'. |
|
| 23 | + // Change to sh1_v2.4 to ensure SilverStripe is using the same hash as FoxyCart API 1.1 |
|
| 24 | + $this->owner->PasswordEncryption = 'sha1_v2.4'; |
|
| 25 | 25 | |
| 26 | - // Send updated customer data to Foxy Cart via API |
|
| 27 | - $response = FoxyCart::putCustomer($this->owner); |
|
| 26 | + // Send updated customer data to Foxy Cart via API |
|
| 27 | + $response = FoxyCart::putCustomer($this->owner); |
|
| 28 | 28 | |
| 29 | - // Grab customer_id record from FoxyCart response, store in Member |
|
| 29 | + // Grab customer_id record from FoxyCart response, store in Member |
|
| 30 | 30 | if($response){ |
| 31 | - $foxyResponse = new SimpleXMLElement($response); |
|
| 32 | - $this->owner->Customer_ID = (int) $foxyResponse->customer_id; |
|
| 31 | + $foxyResponse = new SimpleXMLElement($response); |
|
| 32 | + $this->owner->Customer_ID = (int) $foxyResponse->customer_id; |
|
| 33 | 33 | } |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |