| Total Complexity | 42 |
| Total Lines | 1099 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Standard often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Standard, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | class Standard extends Base |
||
| 22 | implements \Aimeos\MShop\Order\Manager\Base\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface |
||
| 23 | { |
||
| 24 | private $searchConfig = array( |
||
| 25 | 'order.base.id' => array( |
||
| 26 | 'code' => 'order.base.id', |
||
| 27 | 'internalcode' => 'mordba."id"', |
||
| 28 | 'internaldeps' => array( 'LEFT JOIN "mshop_order_base" AS mordba ON ( mord."baseid" = mordba."id" )' ), |
||
| 29 | 'label' => 'Order ID', |
||
| 30 | 'type' => 'integer', |
||
| 31 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
| 32 | 'public' => false, |
||
| 33 | ), |
||
| 34 | 'order.base.siteid' => array( |
||
| 35 | 'code' => 'order.base.siteid', |
||
| 36 | 'internalcode' => 'mordba."siteid"', |
||
| 37 | 'label' => 'Order site ID', |
||
| 38 | 'type' => 'string', |
||
| 39 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 40 | 'public' => false, |
||
| 41 | ), |
||
| 42 | 'order.base.sitecode' => array( |
||
| 43 | 'code' => 'order.base.sitecode', |
||
| 44 | 'internalcode' => 'mordba."sitecode"', |
||
| 45 | 'label' => 'Order site code', |
||
| 46 | 'type' => 'string', |
||
| 47 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 48 | 'public' => false, |
||
| 49 | ), |
||
| 50 | 'order.base.customerid' => array( |
||
| 51 | 'code' => 'order.base.customerid', |
||
| 52 | 'internalcode' => 'mordba."customerid"', |
||
| 53 | 'label' => 'Order customer ID', |
||
| 54 | 'type' => 'string', |
||
| 55 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 56 | ), |
||
| 57 | 'order.base.customerref' => array( |
||
| 58 | 'code' => 'order.base.customerref', |
||
| 59 | 'internalcode' => 'mordba."customerref"', |
||
| 60 | 'label' => 'Order customer reference', |
||
| 61 | 'type' => 'string', |
||
| 62 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 63 | ), |
||
| 64 | 'order.base.languageid' => array( |
||
| 65 | 'code' => 'order.base.languageid', |
||
| 66 | 'internalcode' => 'mordba."langid"', |
||
| 67 | 'label' => 'Order language code', |
||
| 68 | 'type' => 'string', |
||
| 69 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 70 | ), |
||
| 71 | 'order.base.currencyid' => array( |
||
| 72 | 'code' => 'order.base.currencyid', |
||
| 73 | 'internalcode' => 'mordba."currencyid"', |
||
| 74 | 'label' => 'Order currencyid code', |
||
| 75 | 'type' => 'string', |
||
| 76 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 77 | ), |
||
| 78 | 'order.base.price' => array( |
||
| 79 | 'code' => 'order.base.price', |
||
| 80 | 'internalcode' => 'mordba."price"', |
||
| 81 | 'label' => 'Order price amount', |
||
| 82 | 'type' => 'string', |
||
| 83 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 84 | ), |
||
| 85 | 'order.base.costs' => array( |
||
| 86 | 'code' => 'order.base.costs', |
||
| 87 | 'internalcode' => 'mordba."costs"', |
||
| 88 | 'label' => 'Order shipping amount', |
||
| 89 | 'type' => 'string', |
||
| 90 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 91 | ), |
||
| 92 | 'order.base.rebate' => array( |
||
| 93 | 'code' => 'order.base.rebate', |
||
| 94 | 'internalcode' => 'mordba."rebate"', |
||
| 95 | 'label' => 'Order rebate amount', |
||
| 96 | 'type' => 'string', |
||
| 97 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 98 | ), |
||
| 99 | 'order.base.taxvalue' => array( |
||
| 100 | 'code' => 'order.base.taxvalue', |
||
| 101 | 'internalcode' => 'mordba."tax"', |
||
| 102 | 'label' => 'Order tax amount', |
||
| 103 | 'type' => 'string', |
||
| 104 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 105 | ), |
||
| 106 | 'order.base.taxflag' => array( |
||
| 107 | 'code' => 'order.base.taxflag', |
||
| 108 | 'internalcode' => 'mordba."taxflag"', |
||
| 109 | 'label' => 'Order tax flag (0=net, 1=gross)', |
||
| 110 | 'type' => 'string', |
||
| 111 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
| 112 | ), |
||
| 113 | 'order.base.comment' => array( |
||
| 114 | 'code' => 'order.base.comment', |
||
| 115 | 'internalcode' => 'mordba."comment"', |
||
| 116 | 'label' => 'Order comment', |
||
| 117 | 'type' => 'string', |
||
| 118 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 119 | ), |
||
| 120 | 'order.base.ctime' => array( |
||
| 121 | 'code' => 'order.base.ctime', |
||
| 122 | 'internalcode' => 'mordba."ctime"', |
||
| 123 | 'label' => 'Order create date/time', |
||
| 124 | 'type' => 'datetime', |
||
| 125 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 126 | 'public' => false, |
||
| 127 | ), |
||
| 128 | 'order.base.mtime' => array( |
||
| 129 | 'code' => 'order.base.mtime', |
||
| 130 | 'internalcode' => 'mordba."mtime"', |
||
| 131 | 'label' => 'Order modify date/time', |
||
| 132 | 'type' => 'datetime', |
||
| 133 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 134 | 'public' => false, |
||
| 135 | ), |
||
| 136 | 'order.base.editor' => array( |
||
| 137 | 'code' => 'order.base.editor', |
||
| 138 | 'internalcode' => 'mordba."editor"', |
||
| 139 | 'label' => 'Order editor', |
||
| 140 | 'type' => 'string', |
||
| 141 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
| 142 | 'public' => false, |
||
| 143 | ), |
||
| 144 | ); |
||
| 145 | |||
| 146 | |||
| 147 | /** |
||
| 148 | * Initializes the object. |
||
| 149 | * |
||
| 150 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
||
| 151 | */ |
||
| 152 | public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
||
| 156 | } |
||
| 157 | |||
| 158 | |||
| 159 | /** |
||
| 160 | * Counts the number items that are available for the values of the given key. |
||
| 161 | * |
||
| 162 | * @param \Aimeos\MW\Criteria\Iface $search Search criteria |
||
| 163 | * @param array|string $key Search key or list of keys to aggregate items for |
||
| 164 | * @param string|null $value Search key for aggregating the value column |
||
| 165 | * @param string|null $type Type of the aggregation, empty string for count or "sum" or "avg" (average) |
||
| 166 | * @return \Aimeos\Map List of the search keys as key and the number of counted items as value |
||
| 167 | */ |
||
| 168 | public function aggregate( \Aimeos\MW\Criteria\Iface $search, $key, string $value = null, string $type = null ) : \Aimeos\Map |
||
| 260 | } |
||
| 261 | |||
| 262 | |||
| 263 | /** |
||
| 264 | * Removes old entries from the storage. |
||
| 265 | * |
||
| 266 | * @param iterable $siteids List of IDs for sites whose entries should be deleted |
||
| 267 | * @return \Aimeos\MShop\Order\Manager\Base\Iface Manager object for chaining method calls |
||
| 268 | */ |
||
| 269 | public function clear( iterable $siteids ) : \Aimeos\MShop\Common\Manager\Iface |
||
| 279 | } |
||
| 280 | |||
| 281 | |||
| 282 | /** |
||
| 283 | * Creates a new empty item instance |
||
| 284 | * |
||
| 285 | * @param array $values Values the item should be initialized with |
||
| 286 | * @return \Aimeos\MShop\Order\Item\Base\Iface New order base item object |
||
| 287 | */ |
||
| 288 | public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface |
||
| 289 | { |
||
| 290 | $context = $this->context(); |
||
| 291 | $locale = $context->locale(); |
||
| 292 | |||
| 293 | $values['order.base.siteid'] = $locale->getSiteId(); |
||
| 294 | $priceManager = \Aimeos\MShop::create( $context, 'price' ); |
||
| 295 | |||
| 296 | $base = $this->createItemBase( $priceManager->create(), clone $locale, $values ); |
||
| 297 | |||
| 298 | \Aimeos\MShop::create( $context, 'plugin' )->register( $base, 'order' ); |
||
| 299 | |||
| 300 | return $base; |
||
| 301 | } |
||
| 302 | |||
| 303 | |||
| 304 | /** |
||
| 305 | * Creates a search critera object |
||
| 306 | * |
||
| 307 | * @param bool|null $default Add default criteria or NULL for relaxed default criteria |
||
| 308 | * @param bool $site TRUE to add site criteria to show orders with available products only |
||
| 309 | * @return \Aimeos\MW\Criteria\Iface New search criteria object |
||
| 310 | */ |
||
| 311 | public function filter( ?bool $default = false, bool $site = false ) : \Aimeos\MW\Criteria\Iface |
||
| 312 | { |
||
| 313 | $search = parent::filter( $default ); |
||
| 314 | $context = $this->context(); |
||
| 315 | |||
| 316 | if( $default !== false ) |
||
| 317 | { |
||
| 318 | $search->setConditions( $search->and( [ |
||
| 319 | $search->compare( '==', 'order.base.customerid', $context->user() ), |
||
| 320 | $search->getConditions(), |
||
| 321 | ] ) ); |
||
| 322 | } |
||
| 323 | |||
| 324 | if( $site === true ) |
||
| 325 | { |
||
| 326 | $level = \Aimeos\MShop\Locale\Manager\Base::SITE_SUBTREE; |
||
| 327 | $search->setConditions( $search->and( [ |
||
| 328 | $this->getSiteCondition( $search, 'order.base.product.siteid', $level ), |
||
| 329 | $search->getConditions() |
||
| 330 | ] ) ); |
||
| 331 | } |
||
| 332 | |||
| 333 | return $search; |
||
| 334 | } |
||
| 335 | |||
| 336 | |||
| 337 | /** |
||
| 338 | * Removes multiple items. |
||
| 339 | * |
||
| 340 | * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items |
||
| 341 | * @return \Aimeos\MShop\Order\Manager\Base\Iface Manager object for chaining method calls |
||
| 342 | */ |
||
| 343 | public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface |
||
| 344 | { |
||
| 345 | /** mshop/order/manager/base/delete/mysql |
||
| 346 | * Deletes the items matched by the given IDs from the database |
||
| 347 | * |
||
| 348 | * @see mshop/order/manager/base/delete/ansi |
||
| 349 | */ |
||
| 350 | |||
| 351 | /** mshop/order/manager/base/delete/ansi |
||
| 352 | * Deletes the items matched by the given IDs from the database |
||
| 353 | * |
||
| 354 | * Removes the records specified by the given IDs from the order database. |
||
| 355 | * The records must be from the site that is configured via the |
||
| 356 | * context item. |
||
| 357 | * |
||
| 358 | * The ":cond" placeholder is replaced by the name of the ID column and |
||
| 359 | * the given ID or list of IDs while the site ID is bound to the question |
||
| 360 | * mark. |
||
| 361 | * |
||
| 362 | * The SQL statement should conform to the ANSI standard to be |
||
| 363 | * compatible with most relational database systems. This also |
||
| 364 | * includes using double quotes for table and column names. |
||
| 365 | * |
||
| 366 | * @param string SQL statement for deleting items |
||
| 367 | * @since 2014.03 |
||
| 368 | * @category Developer |
||
| 369 | * @see mshop/order/manager/base/insert/ansi |
||
| 370 | * @see mshop/order/manager/base/update/ansi |
||
| 371 | * @see mshop/order/manager/base/newid/ansi |
||
| 372 | * @see mshop/order/manager/base/search/ansi |
||
| 373 | * @see mshop/order/manager/base/count/ansi |
||
| 374 | */ |
||
| 375 | $path = 'mshop/order/manager/base/delete'; |
||
| 376 | |||
| 377 | return $this->deleteItemsBase( $itemIds, $path ); |
||
| 378 | } |
||
| 379 | |||
| 380 | |||
| 381 | /** |
||
| 382 | * Returns the order base item specified by the given ID. |
||
| 383 | * |
||
| 384 | * @param string $id Unique id of the order base |
||
| 385 | * @param string[] $ref List of domains to fetch list items and referenced items for |
||
| 386 | * @param bool|null $default Add default criteria or NULL for relaxed default criteria |
||
| 387 | * @return \Aimeos\MShop\Order\Item\Base\Iface Returns Order base item of the given id |
||
| 388 | * @throws \Aimeos\MShop\Exception If item couldn't be found |
||
| 389 | */ |
||
| 390 | public function get( string $id, array $ref = [], ?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface |
||
| 391 | { |
||
| 392 | return $this->getItemBase( 'order.base.id', $id, $ref, $default ); |
||
| 393 | } |
||
| 394 | |||
| 395 | |||
| 396 | /** |
||
| 397 | * Returns the available manager types |
||
| 398 | * |
||
| 399 | * @param bool $withsub Return also the resource type of sub-managers if true |
||
| 400 | * @return string[] Type of the manager and submanagers, subtypes are separated by slashes |
||
| 401 | */ |
||
| 402 | public function getResourceType( bool $withsub = true ) : array |
||
| 406 | } |
||
| 407 | |||
| 408 | |||
| 409 | /** |
||
| 410 | * Returns the attributes that can be used for searching. |
||
| 411 | * |
||
| 412 | * @param bool $withsub Return also attributes of sub-managers if true |
||
| 413 | * @return \Aimeos\MW\Criteria\Attribute\Iface[] List of search attribute items |
||
| 414 | */ |
||
| 415 | public function getSearchAttributes( bool $withsub = true ) : array |
||
| 438 | } |
||
| 439 | |||
| 440 | |||
| 441 | /** |
||
| 442 | * Returns a new manager for order base extensions. |
||
| 443 | * |
||
| 444 | * @param string $manager Name of the sub manager type in lower case |
||
| 445 | * @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
||
| 446 | * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g address, coupon, product, service, etc. |
||
| 447 | */ |
||
| 448 | public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface |
||
| 449 | { |
||
| 450 | /** mshop/order/manager/base/name |
||
| 451 | * Class name of the used order base manager implementation |
||
| 452 | * |
||
| 453 | * Each default order base manager can be replaced by an alternative imlementation. |
||
| 454 | * To use this implementation, you have to set the last part of the class |
||
| 455 | * name as configuration value so the manager factory knows which class it |
||
| 456 | * has to instantiate. |
||
| 457 | * |
||
| 458 | * For example, if the name of the default class is |
||
| 459 | * |
||
| 460 | * \Aimeos\MShop\Order\Manager\Base\Standard |
||
| 461 | * |
||
| 462 | * and you want to replace it with your own version named |
||
| 463 | * |
||
| 464 | * \Aimeos\MShop\Order\Manager\Base\Mybase |
||
| 465 | * |
||
| 466 | * then you have to set the this configuration option: |
||
| 467 | * |
||
| 468 | * mshop/order/manager/base/name = Mybase |
||
| 469 | * |
||
| 470 | * The value is the last part of your own class name and it's case sensitive, |
||
| 471 | * so take care that the configuration value is exactly named like the last |
||
| 472 | * part of the class name. |
||
| 473 | * |
||
| 474 | * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
||
| 475 | * characters are possible! You should always start the last part of the class |
||
| 476 | * name with an upper case character and continue only with lower case characters |
||
| 477 | * or numbers. Avoid chamel case names like "MyBase"! |
||
| 478 | * |
||
| 479 | * @param string Last part of the class name |
||
| 480 | * @since 2014.03 |
||
| 481 | * @category Developer |
||
| 482 | */ |
||
| 483 | |||
| 484 | /** mshop/order/manager/base/decorators/excludes |
||
| 485 | * Excludes decorators added by the "common" option from the order base manager |
||
| 486 | * |
||
| 487 | * Decorators extend the functionality of a class by adding new aspects |
||
| 488 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 489 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 490 | * modify what is returned to the caller. |
||
| 491 | * |
||
| 492 | * This option allows you to remove a decorator added via |
||
| 493 | * "mshop/common/manager/decorators/default" before they are wrapped |
||
| 494 | * around the order base manager. |
||
| 495 | * |
||
| 496 | * mshop/order/manager/base/decorators/excludes = array( 'decorator1' ) |
||
| 497 | * |
||
| 498 | * This would remove the decorator named "decorator1" from the list of |
||
| 499 | * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via |
||
| 500 | * "mshop/common/manager/decorators/default" for the order base manager. |
||
| 501 | * |
||
| 502 | * @param array List of decorator names |
||
| 503 | * @since 2014.03 |
||
| 504 | * @category Developer |
||
| 505 | * @see mshop/common/manager/decorators/default |
||
| 506 | * @see mshop/order/manager/base/decorators/global |
||
| 507 | * @see mshop/order/manager/base/decorators/local |
||
| 508 | */ |
||
| 509 | |||
| 510 | /** mshop/order/manager/base/decorators/global |
||
| 511 | * Adds a list of globally available decorators only to the order base manager |
||
| 512 | * |
||
| 513 | * Decorators extend the functionality of a class by adding new aspects |
||
| 514 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 515 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 516 | * modify what is returned to the caller. |
||
| 517 | * |
||
| 518 | * This option allows you to wrap global decorators |
||
| 519 | * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the order base |
||
| 520 | * manager. |
||
| 521 | * |
||
| 522 | * mshop/order/manager/base/decorators/global = array( 'decorator1' ) |
||
| 523 | * |
||
| 524 | * This would add the decorator named "decorator1" defined by |
||
| 525 | * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the order |
||
| 526 | * base manager. |
||
| 527 | * |
||
| 528 | * @param array List of decorator names |
||
| 529 | * @since 2014.03 |
||
| 530 | * @category Developer |
||
| 531 | * @see mshop/common/manager/decorators/default |
||
| 532 | * @see mshop/order/manager/base/decorators/excludes |
||
| 533 | * @see mshop/order/manager/base/decorators/local |
||
| 534 | */ |
||
| 535 | |||
| 536 | /** mshop/order/manager/base/decorators/local |
||
| 537 | * Adds a list of local decorators only to the order base manager |
||
| 538 | * |
||
| 539 | * Decorators extend the functionality of a class by adding new aspects |
||
| 540 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 541 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 542 | * modify what is returned to the caller. |
||
| 543 | * |
||
| 544 | * This option allows you to wrap local decorators |
||
| 545 | * ("\Aimeos\MShop\Order\Manager\Base\Decorator\*") around the order base |
||
| 546 | * manager. |
||
| 547 | * |
||
| 548 | * mshop/order/manager/base/decorators/local = array( 'decorator2' ) |
||
| 549 | * |
||
| 550 | * This would add the decorator named "decorator2" defined by |
||
| 551 | * "\Aimeos\MShop\Order\Manager\Base\Decorator\Decorator2" only to the |
||
| 552 | * order base manager. |
||
| 553 | * |
||
| 554 | * @param array List of decorator names |
||
| 555 | * @since 2014.03 |
||
| 556 | * @category Developer |
||
| 557 | * @see mshop/common/manager/decorators/default |
||
| 558 | * @see mshop/order/manager/base/decorators/excludes |
||
| 559 | * @see mshop/order/manager/base/decorators/global |
||
| 560 | */ |
||
| 561 | |||
| 562 | return $this->getSubManagerBase( 'order', 'base/' . $manager, $name ); |
||
| 563 | } |
||
| 564 | |||
| 565 | |||
| 566 | /** |
||
| 567 | * Adds or updates an order base item in the storage. |
||
| 568 | * |
||
| 569 | * @param \Aimeos\MShop\Order\Item\Base\Iface $item Order base object (sub-items are not saved) |
||
| 570 | * @param bool $fetch True if the new ID should be returned in the item |
||
| 571 | * @return \Aimeos\MShop\Order\Item\Base\Iface $item Updated item including the generated ID |
||
| 572 | */ |
||
| 573 | public function saveItem( \Aimeos\MShop\Order\Item\Base\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Order\Item\Base\Iface |
||
| 755 | } |
||
| 756 | |||
| 757 | |||
| 758 | /** |
||
| 759 | * Search for orders based on the given criteria. |
||
| 760 | * |
||
| 761 | * @param \Aimeos\MW\Criteria\Iface $search Search criteria object |
||
| 762 | * @param string[] $ref List of domains to fetch list items and referenced items for, e.g. |
||
| 763 | * "order/base/address", "order/base/coupon", "order/base/product", "order/base/service" |
||
| 764 | * @param int|null &$total Number of items that are available in total |
||
| 765 | * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Order\Item\Base\Iface with ids as keys |
||
| 766 | */ |
||
| 767 | public function search( \Aimeos\MW\Criteria\Iface $search, array $ref = [], int &$total = null ) : \Aimeos\Map |
||
| 944 | } |
||
| 945 | |||
| 946 | |||
| 947 | /** |
||
| 948 | * Creates a new basket containing the items from the order excluding the coupons. |
||
| 949 | * If the last parameter is ture, the items will be marked as new and |
||
| 950 | * modified so an additional order is stored when the basket is saved. |
||
| 951 | * |
||
| 952 | * @param string $id Base ID of the order to load |
||
| 953 | * @param int $parts Bitmap of the basket parts that should be loaded |
||
| 954 | * @param bool $fresh Create a new basket by copying the existing one and remove IDs |
||
| 955 | * @param bool $default True to use default criteria, false for no limitation |
||
| 956 | * @return \Aimeos\MShop\Order\Item\Base\Iface Basket including all items |
||
| 957 | */ |
||
| 958 | public function load( string $id, int $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, bool $fresh = false, |
||
| 1029 | } |
||
| 1030 | |||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Saves the complete basket to the storage including the items attached. |
||
| 1034 | * |
||
| 1035 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object containing all information |
||
| 1036 | * @return \Aimeos\MShop\Order\Item\Base\Iface Stored order basket |
||
| 1037 | */ |
||
| 1038 | public function store( \Aimeos\MShop\Order\Item\Base\Iface $basket ) : \Aimeos\MShop\Order\Item\Base\Iface |
||
| 1048 | } |
||
| 1049 | |||
| 1050 | |||
| 1051 | /** |
||
| 1052 | * Creates the order base item objects from the map and adds the referenced items |
||
| 1053 | * |
||
| 1054 | * @param array $map Associative list of order base IDs as keys and list of price/locale/row as values |
||
| 1055 | * @param string[] $ref Domain items that should be added as well, e.g. |
||
| 1056 | * "order/base/address", "order/base/coupon", "order/base/product", "order/base/service" |
||
| 1057 | * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Order\Item\Base\Iface with IDs as keys |
||
| 1058 | */ |
||
| 1059 | protected function buildItems( array $map, array $ref ) : \Aimeos\Map |
||
| 1098 | } |
||
| 1099 | |||
| 1100 | |||
| 1101 | /** |
||
| 1102 | * Returns a new and empty order base item (shopping basket). |
||
| 1103 | * |
||
| 1104 | * @param \Aimeos\MShop\Price\Item\Iface $price Default price of the basket (usually 0.00) |
||
| 1105 | * @param \Aimeos\MShop\Locale\Item\Iface $locale Locale item containing the site, language and currency |
||
| 1106 | * @param array $values Associative list of key/value pairs containing, e.g. the order or user ID |
||
| 1107 | * @param \Aimeos\MShop\Order\Item\Base\Product\Iface[] $products List of ordered product items |
||
| 1108 | * @param \Aimeos\MShop\Order\Item\Base\Address\Iface[] $addresses List of order address items |
||
| 1109 | * @param \Aimeos\MShop\Order\Item\Base\Service\Iface[] $services List of order serviceitems |
||
| 1110 | * @param \Aimeos\MShop\Order\Item\Base\Product\Iface[] $coupons Associative list of coupon codes as keys and items as values |
||
| 1111 | * @param \Aimeos\MShop\Customer\Item\Iface|null $custItem Customer item object if requested |
||
| 1112 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object |
||
| 1113 | */ |
||
| 1114 | protected function createItemBase( \Aimeos\MShop\Price\Item\Iface $price, \Aimeos\MShop\Locale\Item\Iface $locale, |
||
| 1122 |