protected function addPages() { if ($checkoutPage = CheckoutPage::get()->First()) { $this->getPageDefinitions($checkoutPage); $this->definitions["Pages"]["CheckoutPage"] = "Page where customers finalise (checkout) their order. This page is required.<br />" . ($checkoutPage ? "<a href=\"/admin/pages/edit/show/" . $checkoutPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>"); $this->configs["Pages"]["CheckoutPage"] = $checkoutPage ? "view: <a href=\"" . $checkoutPage->Link() . "\">" . $checkoutPage->Title . "</a><br />" . $checkoutPage->configArray : " NOT CREATED!"; $this->defaults["Pages"]["CheckoutPage"] = $checkoutPage ? $checkoutPage->defaultsArray : "[add page first to see defaults]"; $this->databaseValues["Pages"]["CheckoutPage"] = true; } if ($orderConfirmationPage = OrderConfirmationPage::get()->First()) { $this->getPageDefinitions($orderConfirmationPage); $this->definitions["Pages"]["OrderConfirmationPage"] = "Page where customers review their order after it has been placed. This page is required.<br />" . ($orderConfirmationPage ? "<a href=\"/admin/pages/edit/show/" . $orderConfirmationPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>"); $this->configs["Pages"]["OrderConfirmationPage"] = $orderConfirmationPage ? "view: <a href=\"" . $orderConfirmationPage->Link() . "\">" . $orderConfirmationPage->Title . "</a><br />" . $orderConfirmationPage->configArray : " NOT CREATED!"; $this->defaults["Pages"]["OrderConfirmationPage"] = $orderConfirmationPage ? $orderConfirmationPage->defaultsArray : "[add page first to see defaults]"; $this->databaseValues["Pages"]["OrderConfirmationPage"] = true; } if ($accountPage = AccountPage::get()->First()) { $this->getPageDefinitions($accountPage); $this->definitions["Pages"]["AccountPage"] = "Page where customers can review their account. This page is required.<br />" . ($accountPage ? "<a href=\"/admin/pages/edit/show/" . $accountPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>"); $this->configs["Pages"]["AccountPage"] = $accountPage ? "view: <a href=\"" . $accountPage->Link() . "\">" . $accountPage->Title . "</a><br />" . $accountPage->configArray : " NOT CREATED!"; $this->defaults["Pages"]["AccountPage"] = $accountPage ? $accountPage->defaultsArray : "[add page first to see defaults]"; $this->databaseValues["Pages"]["AccountPage"] = true; } if ($cartPage = CartPage::get()->Filter(array("ClassName" => "CartPage"))->First()) { $this->getPageDefinitions($cartPage); $this->definitions["Pages"]["CartPage"] = "Page where customers review their cart while shopping. This page is optional.<br />" . ($cartPage ? "<a href=\"/admin/pages/edit/show/" . $cartPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>"); $this->configs["Pages"]["CartPage"] = $cartPage ? "view: <a href=\"" . $cartPage->Link() . "\">" . $cartPage->Title . "</a>, <a href=\"/admin/pages/edit/show/" . $cartPage->ID . "/\">edit</a><br />" . $cartPage->configArray : " NOT CREATED!"; $this->defaults["Pages"]["CartPage"] = $cartPage ? $cartPage->defaultsArray : "[add page first to see defaults]"; $this->defaults["Pages"]["CartPage"] = $cartPage ? $cartPage->defaultsArray : "[add page first to see defaults]"; $this->databaseValues["Pages"]["CartPage"] = true; } }
/** * This can be used by admins to log in as customers * to place orders on their behalf... * @param SS_HTTPRequest * @return REDIRECT */ function loginas(SS_HTTPRequest $request) { if (Permission::check("ADMIN") || Permission::check(EcommerceConfig::get("EcommerceRole", "admin_group_code"))) { $newMember = Member::get()->byID(intval($request->param("ID"))); if ($newMember) { $oldMember = Member::currentUser(); if ($oldMember) { $oldMember->logout(); $newMember->login(); if ($accountPage = AccountPage::get()->first()) { return $this->redirect($accountPage->Link()); } else { return $this->redirect(Director::baseURL()); } } else { echo "Another error occurred."; } } else { echo "Can not find this member."; } } else { echo "please <a href=\"Security/login/?BackURL=" . urlencode($this->config()->get("url_segment") . "/debug/") . "\">log in</a> first."; } }
/** * Returns the link to the AccountPage on this site * @return String (URLSegment) */ public static function find_link() { $page = AccountPage::get()->filter(array("ClassName" => "AccountPage"))->First(); if ($page) { return $page->Link(); } }
private function collateexamplepages() { $this->addExamplePages(0, "Checkout page", CheckoutPage::get()->First()); $this->addExamplePages(0, "Order Confirmation page", OrderConfirmationPage::get()->First()); $this->addExamplePages(0, "Cart page (review cart without checkout)", CartPage::get()->where("ClassName = 'CartPage'")->First()); $this->addExamplePages(0, "Account page", AccountPage::get()->First()); //$this->addExamplePages(1, "Donation page", AnyPriceProductPage::get()->First()); $this->addExamplePages(1, "Products that can not be sold", Product::get()->where("\"AllowPurchase\" = 0 AND ClassName = 'Product'")->First()); $this->addExamplePages(1, "Product group with short product display template", ProductGroup::get()->where("\"DisplayStyle\" = 'Short'")->First()); $this->addExamplePages(1, "Product group with medium length product display template", ProductGroup::get()->where("\"DisplayStyle\" = ''")->First()); $this->addExamplePages(1, "Product group with more detail product display template", ProductGroup::get()->where("\"DisplayStyle\" = 'MoreDetail'")->First()); //$this->addExamplePages(1, "Quick Add page", AddToCartPage::get()->first()); //$this->addExamplePages(1, "Shop by Tag page ", ProductGroupWithTags::get()->first()); $this->addExamplePages(2, "Delivery options (add product to cart first)", CheckoutPage::get()->First()); $this->addExamplePages(2, "Taxes (NZ based GST - add product to cart first)", CheckoutPage::get()->first()); $this->addExamplePages(2, "Discount Coupon (try <i>AAA</i>)", CheckoutPage::get()->First()); $this->addExamplePages(4, "Products with zero price", Product::get()->where("\"Price\" = 0 AND ClassName = 'Product'")->First()); //$this->addExamplePages(5, "Corporate Account Order page", AddUpProductsToOrderPage::get()->First()); $html = ' <h2>Some Interesting Features</h2> <p> Below are some features of this e-commerce application that may be of interest to you: </p> <ul> <li>customised search for users with search history graphs for admins</li> <li>ability to check-out with or without adding a password (creating an account)</li> <li>easy to use CMS</li> <li>very fast product listings, making extensive use of caching</li> <li>many ways to display products, allowing the content editor to set things like <i>products per page</i>, <i>product selctions</i>, <i>sorting orders</i></li> <li>multi-currency options and currency conversions</li> <li>step-by-step system for completed orders leading them from being submitted to archived via very steps. This allows the admin to review orders where needed, add extra information, such as tracking codes for delivery, etc...</li> <li>code that is very easy to customise and adjust for your needs</li> <li>a ton of additional modules are available - you can add them directly to your e-commece install or use these as examples for building your own extensions </li> <li>geo-coding for addresses</li> <li>extensive developer assistance through various tools and personalised help</li> </ul> <h2>examples shown on this demo site</h2>'; foreach ($this->examplePages as $key => $exampleGroups) { $html .= "<h3>" . $exampleGroups["Title"] . "</h3><ul>"; foreach ($exampleGroups["List"] as $examplePages) { $html .= '<li><span class="exampleTitle">' . $examplePages["Title"] . '</span>' . $examplePages["List"] . '</li>'; } $html .= "</ul>"; } $html .= ' <h2>API Access</h2> <p> E-commerce allows you to access its model using the built-in Silverstripe API. This is great for communication with third party applications. Access examples are listed below: </p> <ul> <li><a href="/api/v1/Order/">view all orders</a></li> <li><a href="/api/v1/Order/1">view order with ID = 1</a></li> </ul> <p> For more information on the restful server API, you can visit the modules home: <a href="https://github.com/silverstripe/silverstripe-restfulserver">https://github.com/silverstripe/silverstripe-restfulserver</a> to find out more on this topic. </p> '; $featuresPage = Page::get()->where("URLSegment = 'features'")->First(); $featuresPage->Content .= $html; $featuresPage->write(); $featuresPage->Publish('Stage', 'Live'); $featuresPage->flushCache(); }
function run($request) { $update = array(); $orderStep = singleton("OrderStep"); $orderStep->requireDefaultRecords(); // ACCOUNT PAGE $accountPage = AccountPage::get()->First(); if (!$accountPage) { $accountPage = new AccountPage(); $accountPage->Title = 'Account'; $accountPage->MenuTitle = 'Account'; $accountPage->MetaTitle = 'Account'; $accountPage->Content = '<p>This is the account page. It is used for shop users to login and change their member details if they have an account.</p>'; $accountPage->URLSegment = 'account'; $accountPage->ShowInMenus = 0; $accountPage->writeToStage('Stage'); $accountPage->publish('Stage', 'Live'); DB::alteration_message('Account page \'Account\' created', 'created'); } else { DB::alteration_message('No need to create an account page, it already exists.'); } //CHECKOUT PAGE //CHECKOUT PAGE $checkoutPage = CheckoutPage::get()->First(); if (!$checkoutPage) { $checkoutPage = new CheckoutPage(); $checkoutPage->Content = '<p>This is the checkout page. You can edit all the messages in the Content Management System.</p>'; $checkoutPage->Title = 'Checkout'; $checkoutPage->TermsAndConditionsMessage = 'You must agree with the terms and conditions to proceed. '; $checkoutPage->MetaTitle = 'Checkout'; $checkoutPage->MenuTitle = 'Checkout'; $checkoutPage->URLSegment = 'checkout'; $update[] = 'Checkout page \'Checkout\' created'; $checkoutPage->ShowInMenus = 0; DB::alteration_message('new checkout page created.', 'created'); } else { DB::alteration_message('No need to create an checkout page, it already exists.'); } if ($checkoutPage) { if ($checkoutPage->TermsPageID == 0 && ($termsPage = Page::get()->Filter(array("URLSegment" => "terms-and-conditions"))->First())) { $checkoutPage->TermsPageID = $termsPage->ID; DB::alteration_message('terms and conditions page linked.', "created"); } else { DB::alteration_message('No terms and conditions page linked.'); } $checkoutPage->writeToStage('Stage'); $checkoutPage->publish('Stage', 'Live'); DB::alteration_message('Checkout page saved'); $orderConfirmationPage = OrderConfirmationPage::get()->First(); if ($orderConfirmationPage) { DB::alteration_message('No need to create an Order Confirmation Page. It already exists.'); } else { $orderConfirmationPage = new OrderConfirmationPage(); $orderConfirmationPage->ParentID = $checkoutPage->ID; $orderConfirmationPage->Title = 'Order confirmation'; $orderConfirmationPage->MenuTitle = 'Order confirmation'; $orderConfirmationPage->MetaTitle = 'Order confirmation'; $orderConfirmationPage->Content = '<p>This is the order confirmation page. It is used to confirm orders after they have been placed in the checkout page.</p>'; $orderConfirmationPage->URLSegment = 'order-confirmation'; $orderConfirmationPage->ShowInMenus = 0; $orderConfirmationPage->writeToStage('Stage'); $orderConfirmationPage->publish('Stage', 'Live'); DB::alteration_message('Order Confirmation created', 'created'); } } $update = array(); $ecommerceConfig = EcommerceDBConfig::current_ecommerce_db_config(); if ($ecommerceConfig) { if (!$ecommerceConfig->ReceiptEmail) { $ecommerceConfig->ReceiptEmail = Email::config()->admin_email; if (!$ecommerceConfig->ReceiptEmail) { user_error("you must set an AdminEmail (Email::setAdminEmail)", E_USER_NOTICE); } $update[] = "created default entry for ReceiptEmail"; } if (!$ecommerceConfig->NumberOfProductsPerPage) { $ecommerceConfig->NumberOfProductsPerPage = 12; $update[] = "created default entry for NumberOfProductsPerPage"; } if (count($update)) { $ecommerceConfig->write(); DB::alteration_message($ecommerceConfig->ClassName . " created/updated: " . implode(" --- ", $update), 'created'); } } }