_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q257900
Address.toString
test
public function toString($separator = ', ') { $fields = array( $this->Company, $this->getName(), $this->Address, $this->AddressLine2, $this->City, $this->State, $this->PostalCode, $this->Country ); ...
php
{ "resource": "" }
q257901
ShopUserInfo.getAddress
test
public function getAddress() { $address = null; if ($data = $this->getLocationData()) { $address = Address::create(); $address->update($data); $address->ID = 0; //ensure not in db } return $address; }
php
{ "resource": "" }
q257902
CartPageController.CartForm
test
public function CartForm() { $cart = $this->Cart(); if (!$cart) { return false; } $form = CartForm::create($this, 'CartForm', $cart); $this->extend('updateCartForm', $form); return $form; }
php
{ "resource": "" }
q257903
Weight.value
test
public function value($subtotal = 0) { $totalWeight = $this->Weight(); if (!$totalWeight) { return $this->Amount = 0; } $amount = 0; $table = $this->config()->weight_cost; if (!empty($table) && is_array($table)) { // ensure table is sorted ...
php
{ "resource": "" }
q257904
Weight.Weight
test
public function Weight() { if ($this->weight) { return $this->weight; } $weight = 0; $order = $this->Order(); if ($order && $orderItems = $order->Items()) { foreach ($orderItems as $orderItem) { if ($product = $orderItem->Product()) { ...
php
{ "resource": "" }
q257905
OrderItemList.Sum
test
public function Sum($field, $onproduct = false) { $total = 0; foreach ($this->getIterator() as $item) { $quantity = ($field === 'Quantity') ? 1 : $item->Quantity; if (!$onproduct) { $total += $item->$field * $quantity; } elseif ($item->hasMethod($f...
php
{ "resource": "" }
q257906
OrderItemList.SubTotal
test
public function SubTotal() { $result = 0; foreach ($this->getIterator() as $item) { $result += $item->Total(); } return $result; }
php
{ "resource": "" }
q257907
Variation.onBeforeWrite
test
public function onBeforeWrite() { parent::onBeforeWrite(); if (isset($_POST['ProductAttributes']) && is_array($_POST['ProductAttributes'])) { $this->AttributeValues()->setByIDList(array_values($_POST['ProductAttributes'])); } $img = $this->Image(); if ($img && ...
php
{ "resource": "" }
q257908
CheckoutPageController.getViewer
test
public function getViewer($action) { if (CheckoutPage::config()->first_step && $action == 'index') { $action = CheckoutPage::config()->first_step; } return parent::getViewer($action); }
php
{ "resource": "" }
q257909
OrderItem.Product
test
public function Product($forcecurrent = false) { //TODO: this might need some unit testing to make sure it compliles with comment description //ie use live if in cart (however I see no logic for checking cart status) if ($this->ProductID && $this->ProductVersion && !$forcecurrent) { ...
php
{ "resource": "" }
q257910
ProductVariationsExtension.updateCMSFields
test
public function updateCMSFields(FieldList $fields) { $fields->addFieldsToTab('Root.Variations', [ ListboxField::create( 'VariationAttributeTypes', _t(__CLASS__ . '.Attributes', "Attributes"), AttributeType::get()->map('ID', 'Title')->toArray() ...
php
{ "resource": "" }
q257911
ProductVariationsExtension.getVariationByAttributes
test
public function getVariationByAttributes(array $attributes) { if (!is_array($attributes)) { return null; } $attrs = array_filter(array_values($attributes)); $set = Variation::get()->filter('ProductID', $this->owner->ID); foreach ($attrs as $i => $valueid) { ...
php
{ "resource": "" }
q257912
ProductVariationsExtension.generateVariationsFromAttributes
test
public function generateVariationsFromAttributes(AttributeType $attributetype, array $values) { //TODO: introduce transactions here, in case objects get half made etc //if product has variation attribute types if (!empty($values)) { //TODO: get values dataobject set $...
php
{ "resource": "" }
q257913
ProductVariationsExtension.onAfterDelete
test
public function onAfterDelete() { $remove = false; // if a record is staged or live, leave it's variations alone. if (!property_exists($this, 'owner')) { $remove = true; } else { $staged = Versioned::get_by_stage($this->owner->ClassName, 'Stage') ...
php
{ "resource": "" }
q257914
CheckoutComponentConfig.getComponentByType
test
public function getComponentByType($type) { foreach ($this->components as $component) { if ($this->namespaced) { if ($component->Proxy() instanceof $type) { return $component->Proxy(); } } else { if ($component insta...
php
{ "resource": "" }
q257915
CheckoutComponentConfig.getFormFields
test
public function getFormFields() { $fields = FieldList::create(); foreach ($this->getComponents() as $component) { if ($cfields = $component->getFormFields($this->order)) { $fields->merge($cfields); } else { user_error('getFields on ' . get_cla...
php
{ "resource": "" }
q257916
CheckoutComponentConfig.validateData
test
public function validateData($data) { $result = ValidationResult::create(); foreach ($this->getComponents() as $component) { try { $component->validateData($this->order, $this->dependantData($component, $data)); } catch (ValidationException $e) { ...
php
{ "resource": "" }
q257917
CheckoutComponentConfig.getData
test
public function getData() { $data = array(); foreach ($this->getComponents() as $component) { $orderdata = $component->getData($this->order); if (is_array($orderdata)) { $data = array_merge($data, $orderdata); } else { user_error(...
php
{ "resource": "" }
q257918
CheckoutComponentConfig.setData
test
public function setData($data) { foreach ($this->getComponents() as $component) { $component->setData($this->order, $this->dependantData($component, $data)); } }
php
{ "resource": "" }
q257919
CheckoutComponentConfig.dependantData
test
protected function dependantData($component, $data) { if (!$this->namespaced) { //no need to try and get un-namespaced dependant data return $data; } $dependantdata = array(); foreach ($component->dependsOn() as $dependanttype) { $dependant = null; ...
php
{ "resource": "" }
q257920
ShoppingCart.current
test
public function current() { $session = ShopTools::getSession(); //find order by id saved to session (allows logging out and retaining cart contents) if (!$this->order && $sessionid = $session->get(self::config()->cartid_session_name)) { $this->order = Order::get()->filter( ...
php
{ "resource": "" }
q257921
ShoppingCart.setCurrent
test
public function setCurrent(Order $cart) { if (!$cart->IsCart()) { trigger_error('Passed Order object is not cart status', E_ERROR); } $this->order = $cart; $session = ShopTools::getSession(); $session->set(self::config()->cartid_session_name, $cart->ID); ...
php
{ "resource": "" }
q257922
ShoppingCart.findOrMake
test
protected function findOrMake() { if ($this->current()) { return $this->current(); } $this->order = Order::create(); if (Member::config()->login_joins_cart && ($member = Security::getCurrentUser())) { $this->order->MemberID = $member->ID; } $th...
php
{ "resource": "" }
q257923
ShoppingCart.add
test
public function add(Buyable $buyable, $quantity = 1, $filter = []) { $order = $this->findOrMake(); // If an extension throws an exception, error out try { $order->extend('beforeAdd', $buyable, $quantity, $filter); } catch (Exception $exception) { return $this...
php
{ "resource": "" }
q257924
ShoppingCart.remove
test
public function remove(Buyable $buyable, $quantity = null, $filter = []) { $order = $this->current(); if (!$order) { return $this->error(_t(__CLASS__ . '.NoOrder', 'No current order.')); } // If an extension throws an exception, error out try { $orde...
php
{ "resource": "" }
q257925
ShoppingCart.removeOrderItem
test
public function removeOrderItem(OrderItem $item, $quantity = null) { $order = $this->current(); if (!$order) { return $this->error(_t(__CLASS__ . '.NoOrder', 'No current order.')); } if (!$item || $item->OrderID != $order->ID) { return $this->error(_t(__CLAS...
php
{ "resource": "" }
q257926
ShoppingCart.setQuantity
test
public function setQuantity(Buyable $buyable, $quantity = 1, $filter = []) { if ($quantity <= 0) { return $this->remove($buyable, $quantity, $filter); } $item = $this->findOrMakeItem($buyable, $quantity, $filter); if (!$item || !$this->updateOrderItemQuantity($item, $qu...
php
{ "resource": "" }
q257927
ShoppingCart.updateOrderItemQuantity
test
public function updateOrderItemQuantity(OrderItem $item, $quantity = 1, $filter = []) { $order = $this->current(); if (!$order) { return $this->error(_t(__CLASS__ . '.NoOrder', 'No current order.')); } if (!$item || $item->OrderID != $order->ID) { return $th...
php
{ "resource": "" }
q257928
ShoppingCart.findOrMakeItem
test
private function findOrMakeItem(Buyable $buyable, $quantity = 1, $filter = []) { $order = $this->findOrMake(); if (!$buyable || !$order) { return null; } $item = $this->get($buyable, $filter); if (!$item) { $member = Security::getCurrentUser(); ...
php
{ "resource": "" }
q257929
ShoppingCart.get
test
public function get(Buyable $buyable, $customfilter = array()) { $order = $this->current(); if (!$buyable || !$order) { return null; } $buyable = $this->getCorrectBuyable($buyable); $filter = array( 'OrderID' => $order->ID, ); $itemc...
php
{ "resource": "" }
q257930
ShoppingCart.archiveorderid
test
public function archiveorderid($requestedOrderId = null) { $session = ShopTools::getSession(); $sessionId = $session->get(self::config()->cartid_session_name); $order = Order::get() ->filter('Status:not', 'Cart') ->byId($sessionId); if ($order && !$order->IsC...
php
{ "resource": "" }
q257931
FlatTax.value
test
public function value($incoming) { $this->Rate = self::config()->rate; //inclusive tax requires a different calculation return self::config()->exclusive ? $incoming * $this->Rate : $incoming - round($incoming / (1 + $this->Rate), Order::config(...
php
{ "resource": "" }
q257932
ShopTools.price_for_display
test
public static function price_for_display($price) { $currency = ShopConfigExtension::get_site_currency(); $field = DBMoney::create_field(DBMoney::class, 0, 'Price'); $field->setAmount($price); $field->setCurrency($currency); return $field; }
php
{ "resource": "" }
q257933
ProductBulkLoader.imageByFilename
test
public function imageByFilename(&$obj, $val, $record) { $filename = trim(strtolower(Convert::raw2sql($val))); $filenamedashes = str_replace(' ', '-', $filename); if ($filename && $image = Image::get()->whereAny( [ "LOWER(\"FileFilename\") LIKE ...
php
{ "resource": "" }
q257934
ProductBulkLoader.setContent
test
public function setContent(&$obj, $val, $record) { $val = trim($val); if ($val) { $paragraphs = explode("\n", $val); $obj->Content = '<p>' . implode('</p><p>', $paragraphs) . '</p>'; } }
php
{ "resource": "" }
q257935
ShopConfigExtension.getCountriesList
test
public function getCountriesList($prefixisocode = false) { $countries = self::config()->iso_3166_country_codes; asort($countries); if ($allowed = $this->owner->AllowedCountries) { $allowed = json_decode($allowed); if (!empty($allowed)) { $countries = a...
php
{ "resource": "" }
q257936
ShopConfigExtension.getSingleCountry
test
public function getSingleCountry($fullname = false) { $countries = $this->getCountriesList(); if (count($countries) == 1) { if ($fullname) { return array_pop($countries); } else { reset($countries); return key($countries); ...
php
{ "resource": "" }
q257937
ShopConfigExtension.countryCode2name
test
public static function countryCode2name($code) { $codes = self::config()->iso_3166_country_codes; if (isset($codes[$code])) { return $codes[$code]; } return $code; }
php
{ "resource": "" }
q257938
ViewableCartExtension.Cart
test
public function Cart() { $order = ShoppingCart::curr(); if (!$order || !$order->Items() || !$order->Items()->exists()) { return false; } return $order; }
php
{ "resource": "" }
q257939
AttributeType.convertArrayToValues
test
public function convertArrayToValues(array $values) { $set = ArrayList::create(); foreach ($values as $value) { $val = $this->Values()->find('Value', $value); if (!$val) { //TODO: ignore case, if possible $val = AttributeValue::create(); $val-...
php
{ "resource": "" }
q257940
AttributeType.getDropDownField
test
public function getDropDownField($emptystring = null, $values = null) { $values = ($values) ? $values : $this->Values()->sort(['Sort' => 'ASC', 'Value' => 'ASC']); if ($values->exists()) { $field = DropdownField::create( 'ProductAttributes[' . $this->ID . ']', ...
php
{ "resource": "" }
q257941
ProductCategory.ProductsShowable
test
public function ProductsShowable($recursive = true) { // Figure out the categories to check $groupids = array($this->ID); if (!empty($recursive) && self::config()->include_child_groups) { $groupids += $this->AllChildCategoryIDs(); } $products = Product::get()->fil...
php
{ "resource": "" }
q257942
ProductCategory.AllChildCategoryIDs
test
public function AllChildCategoryIDs() { $ids = [$this->ID]; $allids = []; do { $ids = ProductCategory::get() ->filter('ParentID', $ids) ->getIDList(); $allids += $ids; } while (!empty($ids)); return $allids; }
php
{ "resource": "" }
q257943
ProductCategory.ChildCategories
test
public function ChildCategories($recursive = false) { $ids = array($this->ID); if ($recursive) { $ids += $this->AllChildCategoryIDs(); } return ProductCategory::get()->filter('ParentID', $ids); }
php
{ "resource": "" }
q257944
ProductCategory.GroupsMenu
test
public function GroupsMenu() { if ($this->Parent() instanceof ProductCategory) { return $this->Parent()->GroupsMenu(); } return ProductCategory::get() ->filter('ParentID', $this->ID); }
php
{ "resource": "" }
q257945
ProductCategory.NestedTitle
test
public function NestedTitle($level = 10, $separator = ' > ', $field = 'MenuTitle') { $item = $this; while ($item && $level > 0) { $parts[] = $item->{$field}; $item = $item->Parent; $level--; } return implode($separator, array_reverse($parts)); ...
php
{ "resource": "" }
q257946
OrderGridFieldDetailForm_ItemRequest.ItemEditForm
test
public function ItemEditForm() { $form = parent::ItemEditForm(); $printlink = $this->Link('printorder') . '?print=1'; $printwindowjs = <<<JS window.open('$printlink', 'print_order', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 5...
php
{ "resource": "" }
q257947
OrderGridFieldDetailForm_ItemRequest.printorder
test
public function printorder() { Requirements::clear(); //include print javascript, if print argument is provided if (isset($_REQUEST['print']) && $_REQUEST['print']) { Requirements::customScript('if(document.location.href.indexOf(\'print=1\') > 0) {window.print();}'); } ...
php
{ "resource": "" }
q257948
CheckoutStep.nextstep
test
private function nextstep() { $steps = $this->owner->getSteps(); $found = false; foreach ($steps as $step => $class) { //determine if this is the current step if (method_exists($this, $step)) { $found = true; } elseif ($found) { ...
php
{ "resource": "" }
q257949
OrdersAdmin.getList
test
public function getList() { $list = parent::getList(); if ($this->modelClass == Order::class) { // Exclude hidden statuses $list = $list->exclude('Status', Order::config()->hidden_status); $this->extend('updateList', $list); } return $list; ...
php
{ "resource": "" }
q257950
OrdersAdmin.getEditForm
test
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); if ($this->modelClass == Order::class) { /** @var GridFieldConfig $config */ $config = $form ->Fields() ->fieldByName($this->sanitiseClassName(...
php
{ "resource": "" }
q257951
CheckoutFieldFactory.getSubset
test
private function getSubset(FieldList $fields, $subset = array()) { if (empty($subset)) { return $fields; } $subfieldlist = FieldList::create(); foreach ($subset as $field) { if ($field = $fields->fieldByName($field)) { $subfieldlist->push($fiel...
php
{ "resource": "" }
q257952
OrderModifier.modify
test
public function modify($subtotal, $forcecalculation = false) { $order = $this->Order(); $value = ($order->IsCart() || $forcecalculation) ? $this->value($subtotal) : $this->Amount; switch ($this->Type) { case 'Chargable': $subtotal += $value; break;...
php
{ "resource": "" }
q257953
SteppedCheckoutExtension.setupSteps
test
public static function setupSteps($steps = null) { if (!is_array($steps)) { //default steps $steps =[ 'membership' => Membership::class, 'contactdetails' => ContactDetails::class, 'shippingaddress' => Address::class, ...
php
{ "resource": "" }
q257954
SteppedCheckoutExtension.onAfterInit
test
public function onAfterInit() { $action = $this->owner->getRequest()->param('Action'); $steps = $this->getSteps(); if (!ShoppingCart::curr() && !empty($action) && isset($steps[$action])) { Controller::curr()->redirect($this->owner->Link()); return; } }
php
{ "resource": "" }
q257955
SteppedCheckoutExtension.IsCurrentStep
test
public function IsCurrentStep($name) { if ($this->owner->getAction() === $name) { return true; } elseif (!$this->owner->getAction() || $this->owner->getAction() === 'index') { return $this->actionPos($name) === 0; } return false; }
php
{ "resource": "" }
q257956
SteppedCheckoutExtension.actionPos
test
private function actionPos($incoming) { $count = 0; foreach ($this->getSteps() as $action => $step) { if ($action == $incoming) { return $count; } $count++; } }
php
{ "resource": "" }
q257957
CartPage.find_link
test
public static function find_link($urlSegment = false, $action = false, $id = false) { $base = CartPageController::config()->url_segment; if ($page = self::get()->first()) { $base = $page->Link(); } return Controller::join_links($base, $action, $id); }
php
{ "resource": "" }
q257958
ProductCategoryController.Products
test
public function Products($recursive = true) { $products = $this->ProductsShowable($recursive); //sort the products $products = $this->getSorter()->sortList($products); //paginate the products, if necessary $pagelength = ProductCategory::config()->page_length; if ($p...
php
{ "resource": "" }
q257959
ShopCurrency.TrimCents
test
public function TrimCents() { $val = $this->value; if (floor($val) == $val) { return floor($val); } return $val; }
php
{ "resource": "" }
q257960
Product.getCMSFields
test
public function getCMSFields() { $self = $this; $this->beforeUpdateCMSFields( function (FieldList $fields) use ($self) { $fields->fieldByName('Root.Main.Title') ->setTitle(_t(__CLASS__ . '.PageTitle', 'Product Title')); $fields->addFi...
php
{ "resource": "" }
q257961
Product.getCategoryOptions
test
private function getCategoryOptions() { $categories = ProductCategory::get()->map('ID', 'NestedTitle')->toArray(); $categories = [ 0 => _t('SilverStripe\CMS\Model\SiteTree.PARENTTYPE_ROOT', 'Top-level page'), ] + $categories; if ($this->ParentID && !($this->Parent() insta...
php
{ "resource": "" }
q257962
Product.getCategoryOptionsNoParent
test
private function getCategoryOptionsNoParent() { $ancestors = $this->getAncestors()->column('ID'); $categories = ProductCategory::get(); if (!empty($ancestors)) { $categories = $categories->exclude('ID', $ancestors); } return $categories->map('ID', 'NestedTitle')->...
php
{ "resource": "" }
q257963
Product.getCategoryIDs
test
public function getCategoryIDs() { $ids = array(); //ancestors foreach ($this->getAncestors() as $ancestor) { $ids[$ancestor->ID] = $ancestor->ID; } //additional categories $ids += $this->ProductCategories()->getIDList(); return $ids; }
php
{ "resource": "" }
q257964
Product.sellingPrice
test
public function sellingPrice() { $price = $this->BasePrice; //TODO: this is not ideal, because prices manipulations will not happen in a known order $this->extend('updateSellingPrice', $price); //prevent negative values $price = $price < 0 ? 0 : $price; // NOTE: Idea...
php
{ "resource": "" }
q257965
Product.Image
test
public function Image() { $image = $this->getComponent('Image'); $this->extend('updateImage', $image); if ($image && $image->exists()) { return $image; } $image = SiteConfig::current_site_config()->DefaultProductImage(); if ($image && $image->exists()) { ...
php
{ "resource": "" }
q257966
PaymentForm.submitpayment
test
public function submitpayment($data, $form) { $data = $form->getData(); $cancelUrl = $this->getFailureLink() ? $this->getFailureLink() : $this->controller->Link(); $order = $this->config->getOrder(); // final recalculation, before making payment $order->calculate(); ...
php
{ "resource": "" }
q257967
OrderActionsForm.dopayment
test
public function dopayment($data, $form) { if (self::config()->allow_paying && $this->order && $this->order->canPay() ) { // Save payment data from form and process payment $data = $form->getData(); $gateway = (!empty($data['PaymentMethod'])...
php
{ "resource": "" }
q257968
OrderActionsForm.docancel
test
public function docancel($data, $form) { if (self::config()->allow_cancelling && $this->order->canCancel() ) { $this->order->Status = 'MemberCancelled'; $this->order->write(); if (self::config()->email_notification) { OrderEmailNotifie...
php
{ "resource": "" }
q257969
OrderActionsForm.getCCFields
test
protected function getCCFields(array $gateways) { $fieldFactory = new GatewayFieldsFactory(null, array('Card')); $onsiteGateways = array(); $allRequired = array(); foreach ($gateways as $gateway => $title) { if (!GatewayInfo::isOffsite($gateway)) { $requir...
php
{ "resource": "" }
q257970
OrderManipulationExtension.add_session_order
test
public static function add_session_order(Order $order) { $history = self::get_session_order_ids(); if (!is_array($history)) { $history = array(); } $history[$order->ID] = $order->ID; ShopTools::getSession()->set(self::$sessname, $history); }
php
{ "resource": "" }
q257971
OrderManipulationExtension.get_session_order_ids
test
public static function get_session_order_ids() { $history = ShopTools::getSession()->get(self::$sessname); if (!is_array($history)) { $history = null; } return $history; }
php
{ "resource": "" }
q257972
OrderManipulationExtension.orderfromid
test
public function orderfromid() { $request = $this->owner->getRequest(); $id = (int)$request->param('ID'); if (!$id) { $id = (int)$request->postVar('OrderID'); } return $this->allorders()->byID($id); }
php
{ "resource": "" }
q257973
OrderManipulationExtension.ActionsForm
test
public function ActionsForm() { if ($order = $this->orderfromid()) { $form = OrderActionsForm::create($this->owner, 'ActionsForm', $order); $form->extend('updateActionsForm', $order); if (!$form->Actions()->exists()) { return null; } ...
php
{ "resource": "" }
q257974
ShopMemberFactory.create
test
public function create($data) { $result = ValidationResult::create(); if (!Checkout::member_creation_enabled()) { $result->addError( _t('SilverShop\Checkout\Checkout.MembershipIsNotAllowed', 'Creating new memberships is not allowed') ); throw new V...
php
{ "resource": "" }
q257975
MemberExtension.get_by_identifier
test
public static function get_by_identifier($idvalue) { return Member::get()->filter( Member::config()->unique_identifier_field, $idvalue )->first(); }
php
{ "resource": "" }
q257976
MemberExtension.afterMemberLoggedIn
test
public function afterMemberLoggedIn() { if (Member::config()->login_joins_cart && $order = ShoppingCart::singleton()->current()) { $order->MemberID = $this->owner->ID; $order->write(); } }
php
{ "resource": "" }
q257977
MemberExtension.getPastOrders
test
public function getPastOrders() { return Order::get() ->filter('MemberID', $this->owner->ID) ->filter('Status:not', Order::config()->hidden_status); }
php
{ "resource": "" }
q257978
ShopQuantityField.AJAXLinkHiddenField
test
public function AJAXLinkHiddenField() { if ($quantitylink = $this->item->setquantityLink()) { return HiddenField::create( $this->MainID() . '_Quantity_SetQuantityLink' )->setValue($quantitylink)->addExtraClass('ajaxQuantityField_qtylink'); } }
php
{ "resource": "" }
q257979
AddressBook.getExistingAddressFields
test
public function getExistingAddressFields() { $member = Security::getCurrentUser(); if ($member && $member->AddressBook()->exists()) { $addressoptions = $member->AddressBook()->sort('Created', 'DESC')->map('ID', 'toString')->toArray(); $addressoptions['newaddress'] = _t('Silve...
php
{ "resource": "" }
q257980
Order.getCMSFields
test
public function getCMSFields() { $fields = FieldList::create(TabSet::create('Root', Tab::create('Main'))); $fs = '<div class="field">'; $fe = '</div>'; $parts = array( DropdownField::create('Status', $this->fieldLabel('Status'), self::get_order_status_options()), ...
php
{ "resource": "" }
q257981
Order.getDefaultSearchContext
test
public function getDefaultSearchContext() { $context = parent::getDefaultSearchContext(); $fields = $context->getFields(); $validStates = self::config()->placed_status; $statusOptions = array_filter(self::get_order_status_options(), function ($k) use ($validStates) { ret...
php
{ "resource": "" }
q257982
Order.getComponents
test
public function getComponents($componentName, $id = null) { $components = parent::getComponents($componentName, $id); if ($componentName === 'Items' && get_class($components) !== UnsavedRelationList::class) { $query = $components->dataQuery(); $components = OrderItemList::cre...
php
{ "resource": "" }
q257983
Order.calculate
test
public function calculate() { if (!$this->IsCart()) { return $this->Total; } $calculator = OrderTotalCalculator::create($this); return $this->Total = $calculator->calculate(); }
php
{ "resource": "" }
q257984
Order.getModifier
test
public function getModifier($className, $forcecreate = false) { $calculator = OrderTotalCalculator::create($this); return $calculator->getModifier($className, $forcecreate); }
php
{ "resource": "" }
q257985
Order.TotalOutstanding
test
public function TotalOutstanding($includeAuthorized = true) { return round( $this->GrandTotal() - ($includeAuthorized ? $this->TotalPaidOrAuthorized() : $this->TotalPaid()), self::config()->rounding_precision ); }
php
{ "resource": "" }
q257986
Order.Link
test
public function Link() { if (Security::getCurrentUser()) { $link = Controller::join_links(AccountPage::find_link(), 'order', $this->ID); } $link = CheckoutPage::find_link(false, 'order', $this->ID); $this->extend('updateLink', $link); return $link; }
php
{ "resource": "" }
q257987
Order.canPay
test
public function canPay($member = null) { $extended = $this->extendedCan(__FUNCTION__, $member); if ($extended !== null) { return $extended; } if (!in_array($this->Status, self::config()->payable_status)) { return false; } if ($this->TotalOutst...
php
{ "resource": "" }
q257988
Order.canDelete
test
public function canDelete($member = null) { $extended = $this->extendedCan(__FUNCTION__, $member); if ($extended !== null) { return $extended; } return false; }
php
{ "resource": "" }
q257989
Order.canView
test
public function canView($member = null) { $extended = $this->extendedCan(__FUNCTION__, $member); if ($extended !== null) { return $extended; } return true; }
php
{ "resource": "" }
q257990
Order.getName
test
public function getName() { $firstname = $this->FirstName ? $this->FirstName : $this->Member()->FirstName; $surname = $this->FirstName ? $this->Surname : $this->Member()->Surname; return implode(' ', array_filter(array($firstname, $surname))); }
php
{ "resource": "" }
q257991
Order.getBillingAddress
test
public function getBillingAddress() { if (!$this->SeparateBillingAddress && $this->ShippingAddressID === $this->BillingAddressID) { return $this->getShippingAddress(); } else { return $this->getAddress('Billing'); } }
php
{ "resource": "" }
q257992
Order.generateReference
test
public function generateReference() { $reference = str_pad($this->ID, self::$reference_id_padding, '0', STR_PAD_LEFT); $this->extend('generateReference', $reference); $candidate = $reference; //prevent generating references that are the same $count = 0; while (Order...
php
{ "resource": "" }
q257993
Order.onBeforeWrite
test
protected function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->getField('Reference') && in_array($this->Status, self::$placed_status)) { $this->generateReference(); } // perform status transition if ($this->isInDB() && $this->isChanged('Status')) { ...
php
{ "resource": "" }
q257994
Order.onBeforeDelete
test
protected function onBeforeDelete() { foreach ($this->Items() as $item) { $item->delete(); } foreach ($this->Modifiers() as $modifier) { $modifier->delete(); } foreach ($this->OrderStatusLogs() as $logEntry) { $logEntry->delete(); ...
php
{ "resource": "" }
q257995
Order.provideI18nEntities
test
public function provideI18nEntities() { $entities = parent::provideI18nEntities(); // collect all the payment status values foreach ($this->dbObject('Status')->enumValues() as $value) { $key = strtoupper($value); $entities[__CLASS__ . ".STATUS_$key"] = array( ...
php
{ "resource": "" }
q257996
CartEditField.Field
test
public function Field($properties = array()) { $editables = $this->editableItems(); $customcartdata = array( 'Items' => $editables, ); // NOTE: this was originally incorrect - passing just $editables and $customcartdata // which broke modules like Display_Logic. ...
php
{ "resource": "" }
q257997
CartEditField.editableItems
test
protected function editableItems() { $editables = ArrayList::create(); foreach ($this->items as $item) { $buyable = $item->Buyable(); if (!$buyable) { continue; } // If the buyable is a variation, use the belonging product instead for v...
php
{ "resource": "" }
q257998
AccountPage.find_link
test
public static function find_link($urlSegment = false) { $page = self::get_if_account_page_exists(); return ($urlSegment) ? $page->URLSegment : $page->Link(); }
php
{ "resource": "" }
q257999
AccountPage.get_order_link
test
public static function get_order_link($orderID, $urlSegment = false) { $page = self::get_if_account_page_exists(); return ($urlSegment ? $page->URLSegment . '/' : $page->Link()) . 'order/' . $orderID; }
php
{ "resource": "" }