Order.php 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model;
  7. use Magento\Directory\Model\Currency;
  8. use Magento\Framework\Api\AttributeValueFactory;
  9. use Magento\Framework\App\ObjectManager;
  10. use Magento\Framework\Exception\LocalizedException;
  11. use Magento\Framework\Locale\ResolverInterface;
  12. use Magento\Framework\Pricing\PriceCurrencyInterface;
  13. use Magento\Sales\Api\Data\OrderInterface;
  14. use Magento\Sales\Api\Data\OrderItemInterface;
  15. use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
  16. use Magento\Sales\Model\Order\Payment;
  17. use Magento\Sales\Model\Order\ProductOption;
  18. use Magento\Sales\Model\ResourceModel\Order\Address\Collection;
  19. use Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection as CreditmemoCollection;
  20. use Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as InvoiceCollection;
  21. use Magento\Sales\Model\ResourceModel\Order\Item\Collection as ItemCollection;
  22. use Magento\Sales\Model\ResourceModel\Order\Payment\Collection as PaymentCollection;
  23. use Magento\Sales\Model\ResourceModel\Order\Shipment\Collection as ShipmentCollection;
  24. use Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection as TrackCollection;
  25. use Magento\Sales\Model\ResourceModel\Order\Status\History\Collection as HistoryCollection;
  26. use Magento\Sales\Api\OrderItemRepositoryInterface;
  27. use Magento\Framework\Api\SearchCriteriaBuilder;
  28. /**
  29. * Order model
  30. *
  31. * Supported events:
  32. * sales_order_load_after
  33. * sales_order_save_before
  34. * sales_order_save_after
  35. * sales_order_delete_before
  36. * sales_order_delete_after
  37. *
  38. * @api
  39. * @method int getGiftMessageId()
  40. * @method \Magento\Sales\Model\Order setGiftMessageId(int $value)
  41. * @method bool hasBillingAddressId()
  42. * @method \Magento\Sales\Model\Order unsBillingAddressId()
  43. * @method bool hasShippingAddressId()
  44. * @method \Magento\Sales\Model\Order unsShippingAddressId()
  45. * @method int getShippigAddressId()
  46. * @method bool hasCustomerNoteNotify()
  47. * @method bool hasForcedCanCreditmemo()
  48. * @method bool getIsInProcess()
  49. * @method \Magento\Customer\Model\Customer getCustomer()
  50. * @method \Magento\Sales\Model\Order setSendEmail(bool $value)
  51. * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  52. * @SuppressWarnings(PHPMD.TooManyFields)
  53. * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
  54. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  55. * @since 100.0.2
  56. */
  57. class Order extends AbstractModel implements EntityInterface, OrderInterface
  58. {
  59. const ENTITY = 'order';
  60. /**
  61. * Order states
  62. */
  63. const STATE_NEW = 'new';
  64. const STATE_PENDING_PAYMENT = 'pending_payment';
  65. const STATE_PROCESSING = 'processing';
  66. const STATE_COMPLETE = 'complete';
  67. const STATE_CLOSED = 'closed';
  68. const STATE_CANCELED = 'canceled';
  69. const STATE_HOLDED = 'holded';
  70. const STATE_PAYMENT_REVIEW = 'payment_review';
  71. /**
  72. * Order statuses
  73. */
  74. const STATUS_FRAUD = 'fraud';
  75. /**
  76. * Order flags
  77. */
  78. const ACTION_FLAG_CANCEL = 'cancel';
  79. const ACTION_FLAG_HOLD = 'hold';
  80. const ACTION_FLAG_UNHOLD = 'unhold';
  81. const ACTION_FLAG_EDIT = 'edit';
  82. const ACTION_FLAG_CREDITMEMO = 'creditmemo';
  83. const ACTION_FLAG_INVOICE = 'invoice';
  84. const ACTION_FLAG_REORDER = 'reorder';
  85. const ACTION_FLAG_SHIP = 'ship';
  86. const ACTION_FLAG_COMMENT = 'comment';
  87. /**
  88. * Report date types
  89. */
  90. const REPORT_DATE_TYPE_CREATED = 'created';
  91. const REPORT_DATE_TYPE_UPDATED = 'updated';
  92. /**
  93. * @var string
  94. */
  95. protected $_eventPrefix = 'sales_order';
  96. /**
  97. * @var string
  98. */
  99. protected $_eventObject = 'order';
  100. /**
  101. * @var InvoiceCollection
  102. */
  103. protected $_invoices;
  104. /**
  105. * @var TrackCollection
  106. */
  107. protected $_tracks;
  108. /**
  109. * @var ShipmentCollection
  110. */
  111. protected $_shipments;
  112. /**
  113. * @var CreditmemoCollection
  114. */
  115. protected $_creditmemos;
  116. /**
  117. * @var array
  118. */
  119. protected $_relatedObjects = [];
  120. /**
  121. * @var Currency
  122. */
  123. protected $_orderCurrency = null;
  124. /**
  125. * @var Currency|null
  126. */
  127. protected $_baseCurrency = null;
  128. /**
  129. * Array of action flags for canUnhold, canEdit, etc.
  130. *
  131. * @var array
  132. */
  133. protected $_actionFlag = [];
  134. /**
  135. * Flag: if after order placing we can send new email to the customer.
  136. *
  137. * @var bool
  138. */
  139. protected $_canSendNewEmailFlag = true;
  140. /**
  141. * Identifier for history item
  142. *
  143. * @var string
  144. */
  145. protected $entityType = 'order';
  146. /**
  147. * @var \Magento\Store\Model\StoreManagerInterface
  148. */
  149. protected $_storeManager;
  150. /**
  151. * @var \Magento\Sales\Model\Order\Config
  152. */
  153. protected $_orderConfig;
  154. /**
  155. * @var \Magento\Catalog\Api\ProductRepositoryInterface
  156. * @deprecated 100.1.0 Remove unused dependency.
  157. */
  158. protected $productRepository;
  159. /**
  160. * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
  161. */
  162. protected $productListFactory;
  163. /**
  164. * @var \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory
  165. */
  166. protected $_orderItemCollectionFactory;
  167. /**
  168. * @var \Magento\Catalog\Model\Product\Visibility
  169. */
  170. protected $_productVisibility;
  171. /**
  172. * @var \Magento\Sales\Model\Service\InvoiceService
  173. */
  174. protected $invoiceManagement;
  175. /**
  176. * @var \Magento\Directory\Model\CurrencyFactory
  177. */
  178. protected $_currencyFactory;
  179. /**
  180. * @var \Magento\Eav\Model\Config
  181. */
  182. private $_eavConfig;
  183. /**
  184. * @var \Magento\Sales\Model\Order\Status\HistoryFactory
  185. */
  186. protected $_orderHistoryFactory;
  187. /**
  188. * @var \Magento\Sales\Model\ResourceModel\Order\Address\CollectionFactory
  189. */
  190. protected $_addressCollectionFactory;
  191. /**
  192. * @var \Magento\Sales\Model\ResourceModel\Order\Payment\CollectionFactory
  193. */
  194. protected $_paymentCollectionFactory;
  195. /**
  196. * @var \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory
  197. */
  198. protected $_historyCollectionFactory;
  199. /**
  200. * @var \Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory
  201. */
  202. protected $_invoiceCollectionFactory;
  203. /**
  204. * @var \Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory
  205. */
  206. protected $_shipmentCollectionFactory;
  207. /**
  208. * @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\CollectionFactory
  209. */
  210. protected $_memoCollectionFactory;
  211. /**
  212. * @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory
  213. */
  214. protected $_trackCollectionFactory;
  215. /**
  216. * @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
  217. */
  218. protected $salesOrderCollectionFactory;
  219. /**
  220. * @var PriceCurrencyInterface
  221. */
  222. protected $priceCurrency;
  223. /**
  224. * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
  225. */
  226. protected $timezone;
  227. /**
  228. * @var ResolverInterface
  229. */
  230. private $localeResolver;
  231. /**
  232. * @var ProductOption
  233. */
  234. private $productOption;
  235. /**
  236. * @var OrderItemRepositoryInterface
  237. */
  238. private $itemRepository;
  239. /**
  240. * @var SearchCriteriaBuilder
  241. */
  242. private $searchCriteriaBuilder;
  243. /**
  244. * @param \Magento\Framework\Model\Context $context
  245. * @param \Magento\Framework\Registry $registry
  246. * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  247. * @param AttributeValueFactory $customAttributeFactory
  248. * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
  249. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  250. * @param Order\Config $orderConfig
  251. * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
  252. * @param \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory $orderItemCollectionFactory
  253. * @param \Magento\Catalog\Model\Product\Visibility $productVisibility
  254. * @param \Magento\Sales\Api\InvoiceManagementInterface $invoiceManagement
  255. * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
  256. * @param \Magento\Eav\Model\Config $eavConfig
  257. * @param Order\Status\HistoryFactory $orderHistoryFactory
  258. * @param \Magento\Sales\Model\ResourceModel\Order\Address\CollectionFactory $addressCollectionFactory
  259. * @param \Magento\Sales\Model\ResourceModel\Order\Payment\CollectionFactory $paymentCollectionFactory
  260. * @param \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory $historyCollectionFactory
  261. * @param \Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory $invoiceCollectionFactory
  262. * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory $shipmentCollectionFactory
  263. * @param \Magento\Sales\Model\ResourceModel\Order\Creditmemo\CollectionFactory $memoCollectionFactory
  264. * @param \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory $trackCollectionFactory
  265. * @param ResourceModel\Order\CollectionFactory $salesOrderCollectionFactory
  266. * @param PriceCurrencyInterface $priceCurrency
  267. * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productListFactory
  268. * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  269. * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  270. * @param array $data
  271. * @param ResolverInterface $localeResolver
  272. * @param ProductOption|null $productOption
  273. * @param OrderItemRepositoryInterface $itemRepository
  274. * @param SearchCriteriaBuilder $searchCriteriaBuilder
  275. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  276. */
  277. public function __construct(
  278. \Magento\Framework\Model\Context $context,
  279. \Magento\Framework\Registry $registry,
  280. \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
  281. AttributeValueFactory $customAttributeFactory,
  282. \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
  283. \Magento\Store\Model\StoreManagerInterface $storeManager,
  284. \Magento\Sales\Model\Order\Config $orderConfig,
  285. \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
  286. \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory $orderItemCollectionFactory,
  287. \Magento\Catalog\Model\Product\Visibility $productVisibility,
  288. \Magento\Sales\Api\InvoiceManagementInterface $invoiceManagement,
  289. \Magento\Directory\Model\CurrencyFactory $currencyFactory,
  290. \Magento\Eav\Model\Config $eavConfig,
  291. \Magento\Sales\Model\Order\Status\HistoryFactory $orderHistoryFactory,
  292. \Magento\Sales\Model\ResourceModel\Order\Address\CollectionFactory $addressCollectionFactory,
  293. \Magento\Sales\Model\ResourceModel\Order\Payment\CollectionFactory $paymentCollectionFactory,
  294. \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory $historyCollectionFactory,
  295. \Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory $invoiceCollectionFactory,
  296. \Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory $shipmentCollectionFactory,
  297. \Magento\Sales\Model\ResourceModel\Order\Creditmemo\CollectionFactory $memoCollectionFactory,
  298. \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory $trackCollectionFactory,
  299. \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $salesOrderCollectionFactory,
  300. PriceCurrencyInterface $priceCurrency,
  301. \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productListFactory,
  302. \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
  303. \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
  304. array $data = [],
  305. ResolverInterface $localeResolver = null,
  306. ProductOption $productOption = null,
  307. OrderItemRepositoryInterface $itemRepository = null,
  308. SearchCriteriaBuilder $searchCriteriaBuilder = null
  309. ) {
  310. $this->_storeManager = $storeManager;
  311. $this->_orderConfig = $orderConfig;
  312. $this->productRepository = $productRepository;
  313. $this->productListFactory = $productListFactory;
  314. $this->timezone = $timezone;
  315. $this->_orderItemCollectionFactory = $orderItemCollectionFactory;
  316. $this->_productVisibility = $productVisibility;
  317. $this->invoiceManagement = $invoiceManagement;
  318. $this->_currencyFactory = $currencyFactory;
  319. $this->_eavConfig = $eavConfig;
  320. $this->_orderHistoryFactory = $orderHistoryFactory;
  321. $this->_addressCollectionFactory = $addressCollectionFactory;
  322. $this->_paymentCollectionFactory = $paymentCollectionFactory;
  323. $this->_historyCollectionFactory = $historyCollectionFactory;
  324. $this->_invoiceCollectionFactory = $invoiceCollectionFactory;
  325. $this->_shipmentCollectionFactory = $shipmentCollectionFactory;
  326. $this->_memoCollectionFactory = $memoCollectionFactory;
  327. $this->_trackCollectionFactory = $trackCollectionFactory;
  328. $this->salesOrderCollectionFactory = $salesOrderCollectionFactory;
  329. $this->priceCurrency = $priceCurrency;
  330. $this->localeResolver = $localeResolver ?: ObjectManager::getInstance()->get(ResolverInterface::class);
  331. $this->productOption = $productOption ?: ObjectManager::getInstance()->get(ProductOption::class);
  332. $this->itemRepository = $itemRepository ?: ObjectManager::getInstance()
  333. ->get(OrderItemRepositoryInterface::class);
  334. $this->searchCriteriaBuilder = $searchCriteriaBuilder ?: ObjectManager::getInstance()
  335. ->get(SearchCriteriaBuilder::class);
  336. parent::__construct(
  337. $context,
  338. $registry,
  339. $extensionFactory,
  340. $customAttributeFactory,
  341. $resource,
  342. $resourceCollection,
  343. $data
  344. );
  345. }
  346. /**
  347. * Initialize resource model
  348. *
  349. * @return void
  350. */
  351. protected function _construct()
  352. {
  353. $this->_init(\Magento\Sales\Model\ResourceModel\Order::class);
  354. }
  355. /**
  356. * Clear order object data
  357. *
  358. * @param string $key data key
  359. * @return $this
  360. */
  361. public function unsetData($key = null)
  362. {
  363. parent::unsetData($key);
  364. if ($key === null) {
  365. $this->setItems(null);
  366. }
  367. return $this;
  368. }
  369. /**
  370. * Retrieve can flag for action (edit, unhold, etc..)
  371. *
  372. * @param string $action
  373. * @return boolean|null
  374. */
  375. public function getActionFlag($action)
  376. {
  377. if (isset($this->_actionFlag[$action])) {
  378. return $this->_actionFlag[$action];
  379. }
  380. return null;
  381. }
  382. /**
  383. * Set can flag value for action (edit, unhold, etc...)
  384. *
  385. * @param string $action
  386. * @param boolean $flag
  387. * @return $this
  388. */
  389. public function setActionFlag($action, $flag)
  390. {
  391. $this->_actionFlag[$action] = (bool)$flag;
  392. return $this;
  393. }
  394. /**
  395. * Return flag for order if it can sends new email to customer.
  396. *
  397. * @return bool
  398. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  399. */
  400. public function getCanSendNewEmailFlag()
  401. {
  402. return $this->_canSendNewEmailFlag;
  403. }
  404. /**
  405. * Set flag for order if it can sends new email to customer.
  406. *
  407. * @param bool $flag
  408. * @return $this
  409. */
  410. public function setCanSendNewEmailFlag($flag)
  411. {
  412. $this->_canSendNewEmailFlag = (bool)$flag;
  413. return $this;
  414. }
  415. /**
  416. * Load order by system increment identifier
  417. *
  418. * @param string $incrementId
  419. * @return \Magento\Sales\Model\Order
  420. */
  421. public function loadByIncrementId($incrementId)
  422. {
  423. return $this->loadByAttribute('increment_id', $incrementId);
  424. }
  425. /**
  426. * Load order by system increment and store identifiers
  427. *
  428. * @param string $incrementId
  429. * @param string $storeId
  430. * @return \Magento\Sales\Model\Order
  431. */
  432. public function loadByIncrementIdAndStoreId($incrementId, $storeId)
  433. {
  434. $orderCollection = $this->getSalesOrderCollection(
  435. [
  436. 'increment_id' => $incrementId,
  437. 'store_id' => $storeId
  438. ]
  439. );
  440. return $orderCollection->getFirstItem();
  441. }
  442. /**
  443. * Get sales Order collection model populated with data
  444. *
  445. * @param array $filters
  446. * @return \Magento\Sales\Model\ResourceModel\Order\Collection
  447. */
  448. protected function getSalesOrderCollection(array $filters = [])
  449. {
  450. /** @var \Magento\Sales\Model\ResourceModel\Order\Collection $salesOrderCollection */
  451. $salesOrderCollection = $this->salesOrderCollectionFactory->create();
  452. foreach ($filters as $field => $condition) {
  453. $salesOrderCollection->addFieldToFilter($field, $condition);
  454. }
  455. return $salesOrderCollection->load();
  456. }
  457. /**
  458. * Load order by custom attribute value. Attribute value should be unique
  459. *
  460. * @param string $attribute
  461. * @param string $value
  462. * @return $this
  463. */
  464. public function loadByAttribute($attribute, $value)
  465. {
  466. $this->load($value, $attribute);
  467. return $this;
  468. }
  469. /**
  470. * Retrieve store model instance
  471. *
  472. * @return \Magento\Store\Model\Store
  473. */
  474. public function getStore()
  475. {
  476. $storeId = $this->getStoreId();
  477. if ($storeId) {
  478. return $this->_storeManager->getStore($storeId);
  479. }
  480. return $this->_storeManager->getStore();
  481. }
  482. /**
  483. * Retrieve order cancel availability
  484. *
  485. * @return bool
  486. * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  487. * @SuppressWarnings(PHPMD.NPathComplexity)
  488. */
  489. public function canCancel()
  490. {
  491. if (!$this->_canVoidOrder()) {
  492. return false;
  493. }
  494. if ($this->canUnhold()) {
  495. return false;
  496. }
  497. if (!$this->canReviewPayment() && $this->canFetchPaymentReviewUpdate()) {
  498. return false;
  499. }
  500. $allInvoiced = true;
  501. foreach ($this->getAllItems() as $item) {
  502. if ($item->getQtyToInvoice()) {
  503. $allInvoiced = false;
  504. break;
  505. }
  506. }
  507. if ($allInvoiced) {
  508. return false;
  509. }
  510. $state = $this->getState();
  511. if ($this->isCanceled() || $state === self::STATE_COMPLETE || $state === self::STATE_CLOSED) {
  512. return false;
  513. }
  514. if ($this->getActionFlag(self::ACTION_FLAG_CANCEL) === false) {
  515. return false;
  516. }
  517. return true;
  518. }
  519. /**
  520. * Getter whether the payment can be voided
  521. *
  522. * @return bool
  523. */
  524. public function canVoidPayment()
  525. {
  526. return $this->_canVoidOrder() ? $this->getPayment()->canVoid() : false;
  527. }
  528. /**
  529. * Check whether order could be canceled by states and flags
  530. *
  531. * @return bool
  532. */
  533. protected function _canVoidOrder()
  534. {
  535. return !($this->isCanceled() || $this->canUnhold() || $this->isPaymentReview());
  536. }
  537. /**
  538. * Retrieve order invoice availability
  539. *
  540. * @return bool
  541. * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  542. */
  543. public function canInvoice()
  544. {
  545. if ($this->canUnhold() || $this->isPaymentReview()) {
  546. return false;
  547. }
  548. $state = $this->getState();
  549. if ($this->isCanceled() || $state === self::STATE_COMPLETE || $state === self::STATE_CLOSED) {
  550. return false;
  551. }
  552. if ($this->getActionFlag(self::ACTION_FLAG_INVOICE) === false) {
  553. return false;
  554. }
  555. foreach ($this->getAllItems() as $item) {
  556. if ($item->getQtyToInvoice() > 0 && !$item->getLockedDoInvoice()) {
  557. return true;
  558. }
  559. }
  560. return false;
  561. }
  562. /**
  563. * Retrieve order credit memo (refund) availability
  564. *
  565. * @return bool
  566. */
  567. public function canCreditmemo()
  568. {
  569. if ($this->hasForcedCanCreditmemo()) {
  570. return $this->getForcedCanCreditmemo();
  571. }
  572. if ($this->canUnhold() || $this->isPaymentReview() ||
  573. $this->isCanceled() || $this->getState() === self::STATE_CLOSED) {
  574. return false;
  575. }
  576. /**
  577. * We can have problem with float in php (on some server $a=762.73;$b=762.73; $a-$b!=0)
  578. * for this we have additional diapason for 0
  579. * TotalPaid - contains amount, that were not rounded.
  580. */
  581. $totalRefunded = $this->priceCurrency->round($this->getTotalPaid()) - $this->getTotalRefunded();
  582. if (abs($this->getGrandTotal()) < .0001) {
  583. return $this->canCreditmemoForZeroTotal($totalRefunded);
  584. }
  585. return $this->canCreditmemoForZeroTotalRefunded($totalRefunded);
  586. }
  587. /**
  588. * Retrieve credit memo for zero total refunded availability.
  589. *
  590. * @param float $totalRefunded
  591. * @return bool
  592. */
  593. private function canCreditmemoForZeroTotalRefunded($totalRefunded)
  594. {
  595. $isRefundZero = abs($totalRefunded) < .0001;
  596. // Case when Adjustment Fee (adjustment_negative) has been used for first creditmemo
  597. $hasAdjustmentFee = abs($totalRefunded - $this->getAdjustmentNegative()) < .0001;
  598. $hasActionFlag = $this->getActionFlag(self::ACTION_FLAG_EDIT) === false;
  599. if ($isRefundZero || $hasAdjustmentFee || $hasActionFlag) {
  600. return false;
  601. }
  602. return true;
  603. }
  604. /**
  605. * Retrieve credit memo for zero total availability.
  606. *
  607. * @param float $totalRefunded
  608. * @return bool
  609. */
  610. private function canCreditmemoForZeroTotal($totalRefunded)
  611. {
  612. $totalPaid = $this->getTotalPaid();
  613. //check if total paid is less than grandtotal
  614. $checkAmtTotalPaid = $totalPaid <= $this->getGrandTotal();
  615. //case when amount is due for invoice
  616. $hasDueAmount = $this->canInvoice() && ($checkAmtTotalPaid);
  617. //case when paid amount is refunded and order has creditmemo created
  618. $creditmemos = ($this->getCreditmemosCollection() === false) ?
  619. true : (count($this->getCreditmemosCollection()) > 0);
  620. $paidAmtIsRefunded = $this->getTotalRefunded() == $totalPaid && $creditmemos;
  621. if (($hasDueAmount || $paidAmtIsRefunded) ||
  622. (!$checkAmtTotalPaid &&
  623. abs($totalRefunded - $this->getAdjustmentNegative()) < .0001)) {
  624. return false;
  625. }
  626. return true;
  627. }
  628. /**
  629. * Retrieve order hold availability
  630. *
  631. * @return bool
  632. */
  633. public function canHold()
  634. {
  635. $notHoldableStates = [
  636. self::STATE_CANCELED,
  637. self::STATE_PAYMENT_REVIEW,
  638. self::STATE_COMPLETE,
  639. self::STATE_CLOSED,
  640. self::STATE_HOLDED
  641. ];
  642. if (in_array($this->getState(), $notHoldableStates)) {
  643. return false;
  644. }
  645. if ($this->getActionFlag(self::ACTION_FLAG_HOLD) === false) {
  646. return false;
  647. }
  648. return true;
  649. }
  650. /**
  651. * Retrieve order unhold availability
  652. *
  653. * @return bool
  654. */
  655. public function canUnhold()
  656. {
  657. if ($this->getActionFlag(self::ACTION_FLAG_UNHOLD) === false || $this->isPaymentReview()) {
  658. return false;
  659. }
  660. return $this->getState() === self::STATE_HOLDED;
  661. }
  662. /**
  663. * Check if comment can be added to order history
  664. *
  665. * @return bool
  666. */
  667. public function canComment()
  668. {
  669. if ($this->getActionFlag(self::ACTION_FLAG_COMMENT) === false) {
  670. return false;
  671. }
  672. return true;
  673. }
  674. /**
  675. * Retrieve order shipment availability
  676. *
  677. * @return bool
  678. * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  679. */
  680. public function canShip()
  681. {
  682. if ($this->canUnhold() || $this->isPaymentReview()) {
  683. return false;
  684. }
  685. if ($this->getIsVirtual() || $this->isCanceled()) {
  686. return false;
  687. }
  688. if ($this->getActionFlag(self::ACTION_FLAG_SHIP) === false) {
  689. return false;
  690. }
  691. foreach ($this->getAllItems() as $item) {
  692. if ($item->getQtyToShip() > 0 && !$item->getIsVirtual() &&
  693. !$item->getLockedDoShip() && !$this->isRefunded($item)) {
  694. return true;
  695. }
  696. }
  697. return false;
  698. }
  699. /**
  700. * Check if item is refunded.
  701. *
  702. * @param OrderItemInterface $item
  703. * @return bool
  704. */
  705. private function isRefunded(OrderItemInterface $item)
  706. {
  707. return $item->getQtyRefunded() == $item->getQtyOrdered();
  708. }
  709. /**
  710. * Retrieve order edit availability
  711. *
  712. * @return bool
  713. */
  714. public function canEdit()
  715. {
  716. if ($this->canUnhold()) {
  717. return false;
  718. }
  719. $state = $this->getState();
  720. if ($this->isCanceled() ||
  721. $this->isPaymentReview() ||
  722. $state === self::STATE_COMPLETE ||
  723. $state === self::STATE_CLOSED
  724. ) {
  725. return false;
  726. }
  727. if ($this->hasInvoices()) {
  728. return false;
  729. }
  730. if (!$this->getPayment()->getMethodInstance()->canEdit()) {
  731. return false;
  732. }
  733. if ($this->getActionFlag(self::ACTION_FLAG_EDIT) === false) {
  734. return false;
  735. }
  736. return true;
  737. }
  738. /**
  739. * Retrieve order reorder availability
  740. *
  741. * @return bool
  742. */
  743. public function canReorder()
  744. {
  745. return $this->_canReorder(false);
  746. }
  747. /**
  748. * Check the ability to reorder ignoring the availability in stock or status of the ordered products
  749. *
  750. * @return bool
  751. */
  752. public function canReorderIgnoreSalable()
  753. {
  754. return $this->_canReorder(true);
  755. }
  756. /**
  757. * Retrieve order reorder availability
  758. *
  759. * @param bool $ignoreSalable
  760. * @return bool
  761. * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  762. */
  763. protected function _canReorder($ignoreSalable = false)
  764. {
  765. if ($this->canUnhold() || $this->isPaymentReview()) {
  766. return false;
  767. }
  768. if ($this->getActionFlag(self::ACTION_FLAG_REORDER) === false) {
  769. return false;
  770. }
  771. $products = [];
  772. $itemsCollection = $this->getItemsCollection();
  773. foreach ($itemsCollection as $item) {
  774. $products[] = $item->getProductId();
  775. }
  776. if (!empty($products)) {
  777. $productsCollection = $this->productListFactory->create()
  778. ->setStoreId($this->getStoreId())
  779. ->addIdFilter($products)
  780. ->addAttributeToSelect('status')
  781. ->load();
  782. foreach ($itemsCollection as $item) {
  783. $product = $productsCollection->getItemById($item->getProductId());
  784. if (!$product) {
  785. return false;
  786. }
  787. if (!$ignoreSalable && !$product->isSalable()) {
  788. return false;
  789. }
  790. }
  791. }
  792. return true;
  793. }
  794. /**
  795. * Check whether the payment is in payment review state
  796. * In this state order cannot be normally processed. Possible actions can be:
  797. * - accept or deny payment
  798. * - fetch transaction information
  799. *
  800. * @return bool
  801. */
  802. public function isPaymentReview()
  803. {
  804. return $this->getState() === self::STATE_PAYMENT_REVIEW;
  805. }
  806. /**
  807. * Check whether payment can be accepted or denied
  808. *
  809. * @return bool
  810. */
  811. public function canReviewPayment()
  812. {
  813. return $this->isPaymentReview() && $this->getPayment()->canReviewPayment();
  814. }
  815. /**
  816. * Check whether there can be a transaction update fetched for payment in review state
  817. *
  818. * @return bool
  819. */
  820. public function canFetchPaymentReviewUpdate()
  821. {
  822. return $this->isPaymentReview() && $this->getPayment()->canFetchTransactionInfo();
  823. }
  824. /**
  825. * Retrieve order configuration model
  826. *
  827. * @return \Magento\Sales\Model\Order\Config
  828. */
  829. public function getConfig()
  830. {
  831. return $this->_orderConfig;
  832. }
  833. /**
  834. * Place order payments
  835. *
  836. * @return $this
  837. */
  838. protected function _placePayment()
  839. {
  840. $this->getPayment()->place();
  841. return $this;
  842. }
  843. /**
  844. * @inheritdoc
  845. */
  846. public function getPayment()
  847. {
  848. $payment = $this->getData(OrderInterface::PAYMENT);
  849. if ($payment === null) {
  850. $paymentItems = $this->getPaymentsCollection()->getItems();
  851. if (count($paymentItems)) {
  852. $payment = reset($paymentItems);
  853. $this->setData(
  854. OrderInterface::PAYMENT,
  855. $payment
  856. );
  857. }
  858. }
  859. if ($payment) {
  860. $payment->setOrder($this);
  861. }
  862. return $payment;
  863. }
  864. /**
  865. * Sets the billing address, if any, for the order.
  866. *
  867. * @param \Magento\Sales\Api\Data\OrderAddressInterface $address
  868. * @return $this
  869. */
  870. public function setBillingAddress(\Magento\Sales\Api\Data\OrderAddressInterface $address = null)
  871. {
  872. $old = $this->getBillingAddress();
  873. if (!empty($old) && !empty($address)) {
  874. $address->setId($old->getId());
  875. }
  876. if (!empty($address)) {
  877. $address->setEmail($this->getCustomerEmail());
  878. $this->addAddress($address->setAddressType('billing'));
  879. }
  880. return $this;
  881. }
  882. /**
  883. * Declare order shipping address
  884. *
  885. * @param \Magento\Sales\Api\Data\OrderAddressInterface $address
  886. * @return $this
  887. */
  888. public function setShippingAddress(\Magento\Sales\Api\Data\OrderAddressInterface $address = null)
  889. {
  890. $old = $this->getShippingAddress();
  891. if (!empty($old) && !empty($address)) {
  892. $address->setId($old->getId());
  893. }
  894. if (!empty($address)) {
  895. $address->setEmail($this->getCustomerEmail());
  896. $this->addAddress($address->setAddressType('shipping'));
  897. }
  898. return $this;
  899. }
  900. /**
  901. * Retrieve order billing address
  902. *
  903. * @return \Magento\Sales\Api\Data\OrderAddressInterface|null
  904. */
  905. public function getBillingAddress()
  906. {
  907. foreach ($this->getAddresses() as $address) {
  908. if ($address->getAddressType() == 'billing' && !$address->isDeleted()) {
  909. return $address;
  910. }
  911. }
  912. return null;
  913. }
  914. /**
  915. * Retrieve order shipping address
  916. *
  917. * @return \Magento\Sales\Model\Order\Address|null
  918. */
  919. public function getShippingAddress()
  920. {
  921. foreach ($this->getAddresses() as $address) {
  922. if ($address->getAddressType() == 'shipping' && !$address->isDeleted()) {
  923. return $address;
  924. }
  925. }
  926. return null;
  927. }
  928. /**
  929. * @inheritdoc
  930. *
  931. * @param string $state
  932. * @return $this
  933. */
  934. public function setState($state)
  935. {
  936. return $this->setData(self::STATE, $state);
  937. }
  938. /**
  939. * Retrieve frontend label of order status
  940. *
  941. * @return string
  942. * @since 102.0.1
  943. */
  944. public function getFrontendStatusLabel()
  945. {
  946. return $this->getConfig()->getStatusFrontendLabel($this->getStatus());
  947. }
  948. /**
  949. * Retrieve label of order status
  950. *
  951. * @return string
  952. * @throws LocalizedException
  953. */
  954. public function getStatusLabel()
  955. {
  956. return $this->getConfig()->getStatusLabel($this->getStatus());
  957. }
  958. /**
  959. * Add status change information to history
  960. *
  961. * @param string $status
  962. * @param string $comment
  963. * @param bool $isCustomerNotified
  964. * @return $this
  965. */
  966. public function addStatusToHistory($status, $comment = '', $isCustomerNotified = false)
  967. {
  968. $this->addStatusHistoryComment($comment, $status)->setIsCustomerNotified($isCustomerNotified);
  969. return $this;
  970. }
  971. /**
  972. * Add a comment to order.
  973. *
  974. * Different or default status may be specified.
  975. *
  976. * @param string $comment
  977. * @param bool|string $status
  978. * @return OrderStatusHistoryInterface
  979. * @deprecated 101.0.5
  980. * @see addCommentToStatusHistory
  981. */
  982. public function addStatusHistoryComment($comment, $status = false)
  983. {
  984. return $this->addCommentToStatusHistory($comment, $status, false);
  985. }
  986. /**
  987. * Add a comment to order status history.
  988. *
  989. * Different or default status may be specified.
  990. *
  991. * @param string $comment
  992. * @param bool|string $status
  993. * @param bool $isVisibleOnFront
  994. * @return OrderStatusHistoryInterface
  995. * @since 101.0.5
  996. */
  997. public function addCommentToStatusHistory($comment, $status = false, $isVisibleOnFront = false)
  998. {
  999. if (false === $status) {
  1000. $status = $this->getStatus();
  1001. } elseif (true === $status) {
  1002. $status = $this->getConfig()->getStateDefaultStatus($this->getState());
  1003. } else {
  1004. $this->setStatus($status);
  1005. }
  1006. $history = $this->_orderHistoryFactory->create()->setStatus(
  1007. $status
  1008. )->setComment(
  1009. $comment
  1010. )->setEntityName(
  1011. $this->entityType
  1012. )->setIsVisibleOnFront(
  1013. $isVisibleOnFront
  1014. );
  1015. $this->addStatusHistory($history);
  1016. return $history;
  1017. }
  1018. /**
  1019. * Overrides entity id, which will be saved to comments history status
  1020. *
  1021. * @param string $entityName
  1022. * @return $this
  1023. */
  1024. public function setHistoryEntityName($entityName)
  1025. {
  1026. $this->entityType = $entityName;
  1027. return $this;
  1028. }
  1029. /**
  1030. * Return order entity type
  1031. *
  1032. * @return string
  1033. */
  1034. public function getEntityType()
  1035. {
  1036. return $this->entityType;
  1037. }
  1038. /**
  1039. * Place order
  1040. *
  1041. * @return $this
  1042. */
  1043. public function place()
  1044. {
  1045. $this->_eventManager->dispatch('sales_order_place_before', ['order' => $this]);
  1046. $this->_placePayment();
  1047. $this->_eventManager->dispatch('sales_order_place_after', ['order' => $this]);
  1048. return $this;
  1049. }
  1050. /**
  1051. * Hold order
  1052. *
  1053. * @return $this
  1054. * @throws LocalizedException
  1055. */
  1056. public function hold()
  1057. {
  1058. if (!$this->canHold()) {
  1059. throw new LocalizedException(__('A hold action is not available.'));
  1060. }
  1061. $this->setHoldBeforeState($this->getState());
  1062. $this->setHoldBeforeStatus($this->getStatus());
  1063. $this->setState(self::STATE_HOLDED)
  1064. ->setStatus($this->getConfig()->getStateDefaultStatus(self::STATE_HOLDED));
  1065. return $this;
  1066. }
  1067. /**
  1068. * Attempt to unhold the order
  1069. *
  1070. * @return $this
  1071. * @throws LocalizedException
  1072. */
  1073. public function unhold()
  1074. {
  1075. if (!$this->canUnhold()) {
  1076. throw new LocalizedException(__('You cannot remove the hold.'));
  1077. }
  1078. $this->setState($this->getHoldBeforeState())
  1079. ->setStatus($this->getHoldBeforeStatus());
  1080. $this->setHoldBeforeState(null);
  1081. $this->setHoldBeforeStatus(null);
  1082. return $this;
  1083. }
  1084. /**
  1085. * Cancel order
  1086. *
  1087. * @return $this
  1088. */
  1089. public function cancel()
  1090. {
  1091. if ($this->canCancel()) {
  1092. $this->getPayment()->cancel();
  1093. $this->registerCancellation();
  1094. $this->_eventManager->dispatch('order_cancel_after', ['order' => $this]);
  1095. }
  1096. return $this;
  1097. }
  1098. /**
  1099. * Is order status in DB "Fraud detected"
  1100. *
  1101. * @return bool
  1102. */
  1103. public function isFraudDetected()
  1104. {
  1105. return $this->getOrigData(self::STATE) == self::STATE_PAYMENT_REVIEW
  1106. && $this->getOrigData(self::STATUS) == self::STATUS_FRAUD;
  1107. }
  1108. /**
  1109. * Prepare order totals to cancellation
  1110. *
  1111. * @param string $comment
  1112. * @param bool $graceful
  1113. * @return $this
  1114. * @throws LocalizedException
  1115. * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  1116. */
  1117. public function registerCancellation($comment = '', $graceful = true)
  1118. {
  1119. if ($this->canCancel() || $this->isPaymentReview() || $this->isFraudDetected()) {
  1120. $state = self::STATE_CANCELED;
  1121. foreach ($this->getAllItems() as $item) {
  1122. if ($state != self::STATE_PROCESSING && $item->getQtyToRefund()) {
  1123. if ($item->isProcessingAvailable()) {
  1124. $state = self::STATE_PROCESSING;
  1125. } else {
  1126. $state = self::STATE_COMPLETE;
  1127. }
  1128. }
  1129. $item->cancel();
  1130. }
  1131. $this->setSubtotalCanceled($this->getSubtotal() - $this->getSubtotalInvoiced());
  1132. $this->setBaseSubtotalCanceled($this->getBaseSubtotal() - $this->getBaseSubtotalInvoiced());
  1133. $this->setTaxCanceled($this->getTaxAmount() - $this->getTaxInvoiced());
  1134. $this->setBaseTaxCanceled($this->getBaseTaxAmount() - $this->getBaseTaxInvoiced());
  1135. $this->setShippingCanceled($this->getShippingAmount() - $this->getShippingInvoiced());
  1136. $this->setBaseShippingCanceled($this->getBaseShippingAmount() - $this->getBaseShippingInvoiced());
  1137. $this->setDiscountCanceled(abs($this->getDiscountAmount()) - $this->getDiscountInvoiced());
  1138. $this->setBaseDiscountCanceled(abs($this->getBaseDiscountAmount()) - $this->getBaseDiscountInvoiced());
  1139. $this->setTotalCanceled($this->getGrandTotal() - $this->getTotalPaid());
  1140. $this->setBaseTotalCanceled($this->getBaseGrandTotal() - $this->getBaseTotalPaid());
  1141. $this->setState($state)
  1142. ->setStatus($this->getConfig()->getStateDefaultStatus($state));
  1143. if (!empty($comment)) {
  1144. $this->addStatusHistoryComment($comment, false);
  1145. }
  1146. } elseif (!$graceful) {
  1147. throw new LocalizedException(__('We cannot cancel this order.'));
  1148. }
  1149. return $this;
  1150. }
  1151. /**
  1152. * Retrieve tracking numbers
  1153. *
  1154. * @return array
  1155. */
  1156. public function getTrackingNumbers()
  1157. {
  1158. if ($this->getData('tracking_numbers')) {
  1159. return explode(',', $this->getData('tracking_numbers'));
  1160. }
  1161. return [];
  1162. }
  1163. /**
  1164. * Retrieve shipping method
  1165. *
  1166. * @param bool $asObject return carrier code and shipping method data as object
  1167. * @return string|\Magento\Framework\DataObject
  1168. */
  1169. public function getShippingMethod($asObject = false)
  1170. {
  1171. $shippingMethod = parent::getShippingMethod();
  1172. if (!$asObject) {
  1173. return $shippingMethod;
  1174. } else {
  1175. list($carrierCode, $method) = explode('_', $shippingMethod, 2);
  1176. return new \Magento\Framework\DataObject(['carrier_code' => $carrierCode, 'method' => $method]);
  1177. }
  1178. }
  1179. /*********************** ADDRESSES ***************************/
  1180. /**
  1181. * Get addresses collection
  1182. *
  1183. * @return Collection
  1184. */
  1185. public function getAddressesCollection()
  1186. {
  1187. $collection = $this->_addressCollectionFactory->create()->setOrderFilter($this);
  1188. if ($this->getId()) {
  1189. foreach ($collection as $address) {
  1190. $address->setOrder($this);
  1191. }
  1192. }
  1193. return $collection;
  1194. }
  1195. /**
  1196. * Get address by id
  1197. *
  1198. * @param mixed $addressId
  1199. * @return false
  1200. */
  1201. public function getAddressById($addressId)
  1202. {
  1203. foreach ($this->getAddressesCollection() as $address) {
  1204. if ($address->getId() == $addressId) {
  1205. return $address;
  1206. }
  1207. }
  1208. return false;
  1209. }
  1210. /**
  1211. * Add address
  1212. *
  1213. * @param \Magento\Sales\Model\Order\Address $address
  1214. * @return $this
  1215. */
  1216. public function addAddress(\Magento\Sales\Model\Order\Address $address)
  1217. {
  1218. $address->setOrder($this)->setParentId($this->getId());
  1219. if (!$address->getId()) {
  1220. $this->setAddresses(array_merge($this->getAddresses(), [$address]));
  1221. $this->setDataChanges(true);
  1222. }
  1223. return $this;
  1224. }
  1225. /**
  1226. * Get items collection
  1227. *
  1228. * @param array $filterByTypes
  1229. * @param bool $nonChildrenOnly
  1230. * @return ItemCollection
  1231. */
  1232. public function getItemsCollection($filterByTypes = [], $nonChildrenOnly = false)
  1233. {
  1234. $collection = $this->_orderItemCollectionFactory->create()->setOrderFilter($this);
  1235. if ($filterByTypes) {
  1236. $collection->filterByTypes($filterByTypes);
  1237. }
  1238. if ($nonChildrenOnly) {
  1239. $collection->filterByParent();
  1240. }
  1241. if ($this->getId()) {
  1242. foreach ($collection as $item) {
  1243. $item->setOrder($this);
  1244. $this->productOption->add($item);
  1245. }
  1246. }
  1247. return $collection;
  1248. }
  1249. /**
  1250. * Get random items collection without related children
  1251. *
  1252. * @param int $limit
  1253. * @return ItemCollection
  1254. */
  1255. public function getParentItemsRandomCollection($limit = 1)
  1256. {
  1257. return $this->_getItemsRandomCollection($limit, true);
  1258. }
  1259. /**
  1260. * Get random items collection with or without related children
  1261. *
  1262. * @param int $limit
  1263. * @param bool $nonChildrenOnly
  1264. * @return ItemCollection
  1265. */
  1266. protected function _getItemsRandomCollection($limit, $nonChildrenOnly = false)
  1267. {
  1268. $collection = $this->_orderItemCollectionFactory->create()
  1269. ->setOrderFilter($this)
  1270. ->setRandomOrder()
  1271. ->setPageSize($limit);
  1272. if ($nonChildrenOnly) {
  1273. $collection->filterByParent();
  1274. }
  1275. $products = [];
  1276. foreach ($collection as $item) {
  1277. $products[] = $item->getProductId();
  1278. }
  1279. $productsCollection = $this->productListFactory->create()->addIdFilter(
  1280. $products
  1281. )->setVisibility(
  1282. $this->_productVisibility->getVisibleInSiteIds()
  1283. )->addPriceData()->load();
  1284. foreach ($collection as $item) {
  1285. $product = $productsCollection->getItemById($item->getProductId());
  1286. if ($product) {
  1287. $item->setProduct($product);
  1288. }
  1289. }
  1290. return $collection;
  1291. }
  1292. /**
  1293. * Get all items
  1294. *
  1295. * @return \Magento\Sales\Model\Order\Item[]
  1296. */
  1297. public function getAllItems()
  1298. {
  1299. $items = [];
  1300. foreach ($this->getItems() as $item) {
  1301. if (!$item->isDeleted()) {
  1302. $items[] = $item;
  1303. }
  1304. }
  1305. return $items;
  1306. }
  1307. /**
  1308. * Get all visible items
  1309. *
  1310. * @return array
  1311. */
  1312. public function getAllVisibleItems()
  1313. {
  1314. $items = [];
  1315. foreach ($this->getItems() as $item) {
  1316. if (!$item->isDeleted() && !$item->getParentItemId()) {
  1317. $items[] = $item;
  1318. }
  1319. }
  1320. return $items;
  1321. }
  1322. /**
  1323. * Gets order item by given ID.
  1324. *
  1325. * @param int $itemId
  1326. * @return \Magento\Framework\DataObject|null
  1327. */
  1328. public function getItemById($itemId)
  1329. {
  1330. $items = $this->getItems();
  1331. if (isset($items[$itemId])) {
  1332. return $items[$itemId];
  1333. }
  1334. return null;
  1335. }
  1336. /**
  1337. * Get item by quote item id
  1338. *
  1339. * @param mixed $quoteItemId
  1340. * @return \Magento\Framework\DataObject|null
  1341. */
  1342. public function getItemByQuoteItemId($quoteItemId)
  1343. {
  1344. foreach ($this->getItems() as $item) {
  1345. if ($item->getQuoteItemId() == $quoteItemId) {
  1346. return $item;
  1347. }
  1348. }
  1349. return null;
  1350. }
  1351. /**
  1352. * Add item
  1353. *
  1354. * @param \Magento\Sales\Model\Order\Item $item
  1355. * @return $this
  1356. */
  1357. public function addItem(\Magento\Sales\Model\Order\Item $item)
  1358. {
  1359. $item->setOrder($this);
  1360. if (!$item->getId()) {
  1361. $this->setItems(array_merge($this->getItems(), [$item]));
  1362. }
  1363. return $this;
  1364. }
  1365. /*********************** PAYMENTS ***************************/
  1366. /**
  1367. * Get payments collection
  1368. *
  1369. * @return PaymentCollection
  1370. */
  1371. public function getPaymentsCollection()
  1372. {
  1373. $collection = $this->_paymentCollectionFactory->create()->setOrderFilter($this);
  1374. if ($this->getId()) {
  1375. foreach ($collection as $payment) {
  1376. $payment->setOrder($this);
  1377. }
  1378. }
  1379. return $collection;
  1380. }
  1381. /**
  1382. * Get all payments
  1383. *
  1384. * @return array
  1385. */
  1386. public function getAllPayments()
  1387. {
  1388. $payments = [];
  1389. foreach ($this->getPaymentsCollection() as $payment) {
  1390. if (!$payment->isDeleted()) {
  1391. $payments[] = $payment;
  1392. }
  1393. }
  1394. return $payments;
  1395. }
  1396. /**
  1397. * Get payment by id
  1398. *
  1399. * @param mixed $paymentId
  1400. * @return Payment|false
  1401. */
  1402. public function getPaymentById($paymentId)
  1403. {
  1404. foreach ($this->getPaymentsCollection() as $payment) {
  1405. if ($payment->getId() == $paymentId) {
  1406. return $payment;
  1407. }
  1408. }
  1409. return false;
  1410. }
  1411. /**
  1412. * @inheritdoc
  1413. */
  1414. public function setPayment(\Magento\Sales\Api\Data\OrderPaymentInterface $payment = null)
  1415. {
  1416. $this->setData(OrderInterface::PAYMENT, $payment);
  1417. if ($payment !== null) {
  1418. $payment->setOrder($this)->setParentId($this->getId());
  1419. if (!$payment->getId()) {
  1420. $this->setDataChanges(true);
  1421. }
  1422. }
  1423. return $payment;
  1424. }
  1425. /*********************** STATUSES ***************************/
  1426. /**
  1427. * Return collection of order status history items.
  1428. *
  1429. * @return HistoryCollection
  1430. */
  1431. public function getStatusHistoryCollection()
  1432. {
  1433. $collection = $this->_historyCollectionFactory->create()->setOrderFilter($this)
  1434. ->setOrder('created_at', 'desc')
  1435. ->setOrder('entity_id', 'desc');
  1436. if ($this->getId()) {
  1437. foreach ($collection as $status) {
  1438. $status->setOrder($this);
  1439. }
  1440. }
  1441. return $collection;
  1442. }
  1443. /**
  1444. * Return array of order status history items without deleted.
  1445. *
  1446. * @return array
  1447. */
  1448. public function getAllStatusHistory()
  1449. {
  1450. $history = [];
  1451. foreach ($this->getStatusHistoryCollection() as $status) {
  1452. if (!$status->isDeleted()) {
  1453. $history[] = $status;
  1454. }
  1455. }
  1456. return $history;
  1457. }
  1458. /**
  1459. * Return collection of visible on frontend order status history items.
  1460. *
  1461. * @return array
  1462. */
  1463. public function getVisibleStatusHistory()
  1464. {
  1465. $history = [];
  1466. foreach ($this->getStatusHistoryCollection() as $status) {
  1467. if (!$status->isDeleted() && $status->getComment() && $status->getIsVisibleOnFront()) {
  1468. $history[] = $status;
  1469. }
  1470. }
  1471. return $history;
  1472. }
  1473. /**
  1474. * Get status history by id
  1475. *
  1476. * @param mixed $statusId
  1477. * @return string|false
  1478. */
  1479. public function getStatusHistoryById($statusId)
  1480. {
  1481. foreach ($this->getStatusHistoryCollection() as $status) {
  1482. if ($status->getId() == $statusId) {
  1483. return $status;
  1484. }
  1485. }
  1486. return false;
  1487. }
  1488. /**
  1489. * @inheritdoc
  1490. *
  1491. * Adds the object to the status history collection, which is automatically saved when the order is saved.
  1492. * See the entity_id attribute backend model.
  1493. * Or the history record can be saved standalone after this.
  1494. *
  1495. * @param \Magento\Sales\Model\Order\Status\History $history
  1496. * @return $this
  1497. */
  1498. public function addStatusHistory(\Magento\Sales\Model\Order\Status\History $history)
  1499. {
  1500. $history->setOrder($this);
  1501. $this->setStatus($history->getStatus());
  1502. if (!$history->getId()) {
  1503. $this->setStatusHistories(array_merge($this->getStatusHistories(), [$history]));
  1504. $this->setDataChanges(true);
  1505. }
  1506. return $this;
  1507. }
  1508. /**
  1509. * Get real order id
  1510. *
  1511. * @return string
  1512. */
  1513. public function getRealOrderId()
  1514. {
  1515. $id = $this->getData('real_order_id');
  1516. if ($id === null) {
  1517. $id = $this->getIncrementId();
  1518. }
  1519. return $id;
  1520. }
  1521. /**
  1522. * Get currency model instance. Will be used currency with which order placed
  1523. *
  1524. * @return Currency
  1525. */
  1526. public function getOrderCurrency()
  1527. {
  1528. if ($this->_orderCurrency === null) {
  1529. $this->_orderCurrency = $this->_currencyFactory->create();
  1530. $this->_orderCurrency->load($this->getOrderCurrencyCode());
  1531. }
  1532. return $this->_orderCurrency;
  1533. }
  1534. /**
  1535. * Get formatted price value including order currency rate to order website currency
  1536. *
  1537. * @param float $price
  1538. * @param bool $addBrackets
  1539. * @return string
  1540. */
  1541. public function formatPrice($price, $addBrackets = false)
  1542. {
  1543. return $this->formatPricePrecision($price, 2, $addBrackets);
  1544. }
  1545. /**
  1546. * Format price precision
  1547. *
  1548. * @param float $price
  1549. * @param int $precision
  1550. * @param bool $addBrackets
  1551. * @return string
  1552. */
  1553. public function formatPricePrecision($price, $precision, $addBrackets = false)
  1554. {
  1555. return $this->getOrderCurrency()->formatPrecision($price, $precision, [], true, $addBrackets);
  1556. }
  1557. /**
  1558. * Retrieve text formatted price value including order rate
  1559. *
  1560. * @param float $price
  1561. * @return string
  1562. */
  1563. public function formatPriceTxt($price)
  1564. {
  1565. return $this->getOrderCurrency()->formatTxt($price);
  1566. }
  1567. /**
  1568. * Retrieve order website currency for working with base prices
  1569. *
  1570. * @return Currency
  1571. */
  1572. public function getBaseCurrency()
  1573. {
  1574. if ($this->_baseCurrency === null) {
  1575. $this->_baseCurrency = $this->_currencyFactory->create()->load($this->getBaseCurrencyCode());
  1576. }
  1577. return $this->_baseCurrency;
  1578. }
  1579. /**
  1580. * Format base price
  1581. *
  1582. * @param float $price
  1583. * @return string
  1584. */
  1585. public function formatBasePrice($price)
  1586. {
  1587. return $this->formatBasePricePrecision($price, 2);
  1588. }
  1589. /**
  1590. * Format Base Price Precision
  1591. *
  1592. * @param float $price
  1593. * @param int $precision
  1594. * @return string
  1595. */
  1596. public function formatBasePricePrecision($price, $precision)
  1597. {
  1598. return $this->getBaseCurrency()->formatPrecision($price, $precision);
  1599. }
  1600. /**
  1601. * Is currency different
  1602. *
  1603. * @return bool
  1604. */
  1605. public function isCurrencyDifferent()
  1606. {
  1607. return $this->getOrderCurrencyCode() != $this->getBaseCurrencyCode();
  1608. }
  1609. /**
  1610. * Retrieve order total due value
  1611. *
  1612. * @return float|null
  1613. */
  1614. public function getTotalDue()
  1615. {
  1616. $total = $this->getGrandTotal() - $this->getTotalPaid();
  1617. $total = $this->priceCurrency->round($total);
  1618. return max($total, 0);
  1619. }
  1620. /**
  1621. * Retrieve order total due value
  1622. *
  1623. * @return float|null
  1624. */
  1625. public function getBaseTotalDue()
  1626. {
  1627. $total = $this->getBaseGrandTotal() - $this->getBaseTotalPaid();
  1628. $total = $this->priceCurrency->round($total);
  1629. return max($total, 0);
  1630. }
  1631. /**
  1632. * Get data
  1633. *
  1634. * @param string $key
  1635. * @param null|string|int $index
  1636. * @return mixed
  1637. */
  1638. public function getData($key = '', $index = null)
  1639. {
  1640. if ($key == 'total_due') {
  1641. return $this->getTotalDue();
  1642. }
  1643. if ($key == 'base_total_due') {
  1644. return $this->getBaseTotalDue();
  1645. }
  1646. return parent::getData($key, $index);
  1647. }
  1648. /**
  1649. * Retrieve order invoices collection
  1650. *
  1651. * @return InvoiceCollection
  1652. */
  1653. public function getInvoiceCollection()
  1654. {
  1655. if ($this->_invoices === null) {
  1656. $this->_invoices = $this->_invoiceCollectionFactory->create()->setOrderFilter($this);
  1657. if ($this->getId()) {
  1658. foreach ($this->_invoices as $invoice) {
  1659. $invoice->setOrder($this);
  1660. }
  1661. }
  1662. }
  1663. return $this->_invoices;
  1664. }
  1665. /**
  1666. * @inheritdoc
  1667. *
  1668. * @param InvoiceCollection $invoices
  1669. * @return $this
  1670. */
  1671. public function setInvoiceCollection(InvoiceCollection $invoices)
  1672. {
  1673. $this->_invoices = $invoices;
  1674. return $this;
  1675. }
  1676. /**
  1677. * Retrieve order shipments collection
  1678. *
  1679. * @return ShipmentCollection|false
  1680. */
  1681. public function getShipmentsCollection()
  1682. {
  1683. if (empty($this->_shipments)) {
  1684. if ($this->getId()) {
  1685. $this->_shipments = $this->_shipmentCollectionFactory->create()->setOrderFilter($this)->load();
  1686. } else {
  1687. return false;
  1688. }
  1689. }
  1690. return $this->_shipments;
  1691. }
  1692. /**
  1693. * Retrieve order creditmemos collection
  1694. *
  1695. * @return CreditmemoCollection|false
  1696. */
  1697. public function getCreditmemosCollection()
  1698. {
  1699. if (empty($this->_creditmemos)) {
  1700. if ($this->getId()) {
  1701. $this->_creditmemos = $this->_memoCollectionFactory->create()->setOrderFilter($this)->load();
  1702. } else {
  1703. return false;
  1704. }
  1705. }
  1706. return $this->_creditmemos;
  1707. }
  1708. /**
  1709. * Retrieve order tracking numbers collection
  1710. *
  1711. * @return TrackCollection
  1712. */
  1713. public function getTracksCollection()
  1714. {
  1715. if (empty($this->_tracks)) {
  1716. $this->_tracks = $this->_trackCollectionFactory->create()->setOrderFilter($this);
  1717. if ($this->getId()) {
  1718. $this->_tracks->load();
  1719. }
  1720. }
  1721. return $this->_tracks;
  1722. }
  1723. /**
  1724. * Check order invoices availability
  1725. *
  1726. * @return bool
  1727. */
  1728. public function hasInvoices()
  1729. {
  1730. return (bool)$this->getInvoiceCollection()->count();
  1731. }
  1732. /**
  1733. * Check order shipments availability
  1734. *
  1735. * @return bool
  1736. */
  1737. public function hasShipments()
  1738. {
  1739. return (bool)$this->getShipmentsCollection()->count();
  1740. }
  1741. /**
  1742. * Check order creditmemos availability
  1743. *
  1744. * @return bool
  1745. */
  1746. public function hasCreditmemos()
  1747. {
  1748. return (bool)$this->getCreditmemosCollection()->count();
  1749. }
  1750. /**
  1751. * Retrieve array of related objects
  1752. *
  1753. * Used for order saving
  1754. *
  1755. * @return array
  1756. */
  1757. public function getRelatedObjects()
  1758. {
  1759. return $this->_relatedObjects;
  1760. }
  1761. /**
  1762. * Get customer name
  1763. *
  1764. * @return string
  1765. */
  1766. public function getCustomerName()
  1767. {
  1768. if ($this->getCustomerFirstname()) {
  1769. $customerName = $this->getCustomerFirstname() . ' ' . $this->getCustomerLastname();
  1770. } else {
  1771. $customerName = (string)__('Guest');
  1772. }
  1773. return $customerName;
  1774. }
  1775. /**
  1776. * Add New object to related array
  1777. *
  1778. * @param \Magento\Framework\Model\AbstractModel $object
  1779. * @return $this
  1780. */
  1781. public function addRelatedObject(\Magento\Framework\Model\AbstractModel $object)
  1782. {
  1783. $this->_relatedObjects[] = $object;
  1784. return $this;
  1785. }
  1786. /**
  1787. * Get formatted order created date in store timezone
  1788. *
  1789. * @param int $format date format type (\IntlDateFormatter::SHORT|\IntlDateFormatter::MEDIUM
  1790. * |\IntlDateFormatter::LONG|\IntlDateFormatter::FULL)
  1791. * @return string
  1792. */
  1793. public function getCreatedAtFormatted($format)
  1794. {
  1795. return $this->timezone->formatDateTime(
  1796. new \DateTime($this->getCreatedAt()),
  1797. $format,
  1798. $format,
  1799. $this->localeResolver->getDefaultLocale(),
  1800. $this->timezone->getConfigTimezone('store', $this->getStore())
  1801. );
  1802. }
  1803. /**
  1804. * Get email customer note
  1805. *
  1806. * @return string
  1807. */
  1808. public function getEmailCustomerNote()
  1809. {
  1810. if ($this->getCustomerNoteNotify()) {
  1811. return $this->getCustomerNote();
  1812. }
  1813. return '';
  1814. }
  1815. /**
  1816. * Get store group name
  1817. *
  1818. * @return string
  1819. */
  1820. public function getStoreGroupName()
  1821. {
  1822. $storeId = $this->getStoreId();
  1823. if ($storeId === null) {
  1824. return $this->getStoreName(1);
  1825. }
  1826. return $this->getStore()->getGroup()->getName();
  1827. }
  1828. /**
  1829. * Reset all data in object so after another load it will be complete new object.
  1830. *
  1831. * @return $this
  1832. */
  1833. public function reset()
  1834. {
  1835. $this->unsetData();
  1836. $this->_actionFlag = [];
  1837. $this->setAddresses(null);
  1838. $this->setItems(null);
  1839. $this->setPayment(null);
  1840. $this->setStatusHistories(null);
  1841. $this->_invoices = null;
  1842. $this->_tracks = null;
  1843. $this->_shipments = null;
  1844. $this->_creditmemos = null;
  1845. $this->_relatedObjects = [];
  1846. $this->_orderCurrency = null;
  1847. $this->_baseCurrency = null;
  1848. return $this;
  1849. }
  1850. /**
  1851. * Get order is not virtual
  1852. *
  1853. * @return bool
  1854. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  1855. */
  1856. public function getIsNotVirtual()
  1857. {
  1858. return !$this->getIsVirtual();
  1859. }
  1860. /**
  1861. * Create new invoice with maximum qty for invoice for each item
  1862. *
  1863. * @param array $qtys
  1864. * @return \Magento\Sales\Model\Order\Invoice
  1865. */
  1866. public function prepareInvoice($qtys = [])
  1867. {
  1868. return $this->invoiceManagement->prepareInvoice($this, $qtys);
  1869. }
  1870. /**
  1871. * Check whether order is canceled
  1872. *
  1873. * @return bool
  1874. */
  1875. public function isCanceled()
  1876. {
  1877. return $this->getState() === self::STATE_CANCELED;
  1878. }
  1879. /**
  1880. * Return increment id
  1881. *
  1882. * @codeCoverageIgnore
  1883. *
  1884. * @return string
  1885. */
  1886. public function getIncrementId()
  1887. {
  1888. return $this->getData('increment_id');
  1889. }
  1890. /**
  1891. * Get Items
  1892. *
  1893. * @return \Magento\Sales\Api\Data\OrderItemInterface[]
  1894. */
  1895. public function getItems()
  1896. {
  1897. if ($this->getData(OrderInterface::ITEMS) == null) {
  1898. $this->searchCriteriaBuilder->addFilter(OrderItemInterface::ORDER_ID, $this->getId());
  1899. $searchCriteria = $this->searchCriteriaBuilder->create();
  1900. $this->setData(
  1901. OrderInterface::ITEMS,
  1902. $this->itemRepository->getList($searchCriteria)->getItems()
  1903. );
  1904. }
  1905. return $this->getData(OrderInterface::ITEMS);
  1906. }
  1907. /**
  1908. * @inheritdoc
  1909. * @codeCoverageIgnore
  1910. */
  1911. public function setItems($items)
  1912. {
  1913. return $this->setData(OrderInterface::ITEMS, $items);
  1914. }
  1915. /**
  1916. * Get addresses
  1917. *
  1918. * @return \Magento\Sales\Api\Data\OrderAddressInterface[]
  1919. */
  1920. public function getAddresses()
  1921. {
  1922. if ($this->getData('addresses') == null) {
  1923. $this->setData(
  1924. 'addresses',
  1925. $this->getAddressesCollection()->getItems()
  1926. );
  1927. }
  1928. return $this->getData('addresses');
  1929. }
  1930. /**
  1931. * Get status History
  1932. *
  1933. * @return \Magento\Sales\Api\Data\OrderStatusHistoryInterface[]|null
  1934. */
  1935. public function getStatusHistories()
  1936. {
  1937. if ($this->getData(OrderInterface::STATUS_HISTORIES) == null) {
  1938. $this->setData(
  1939. OrderInterface::STATUS_HISTORIES,
  1940. $this->getStatusHistoryCollection()->getItems()
  1941. );
  1942. }
  1943. return $this->getData(OrderInterface::STATUS_HISTORIES);
  1944. }
  1945. /**
  1946. * @inheritdoc
  1947. *
  1948. * @return \Magento\Sales\Api\Data\OrderExtensionInterface|null
  1949. */
  1950. public function getExtensionAttributes()
  1951. {
  1952. return $this->_getExtensionAttributes();
  1953. }
  1954. /**
  1955. * @inheritdoc
  1956. *
  1957. * @param \Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes
  1958. * @return $this
  1959. */
  1960. public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes)
  1961. {
  1962. return $this->_setExtensionAttributes($extensionAttributes);
  1963. }
  1964. //@codeCoverageIgnoreStart
  1965. /**
  1966. * Return adjustment_negative
  1967. *
  1968. * @return float|null
  1969. */
  1970. public function getAdjustmentNegative()
  1971. {
  1972. return $this->getData(OrderInterface::ADJUSTMENT_NEGATIVE);
  1973. }
  1974. /**
  1975. * Return adjustment_positive
  1976. *
  1977. * @return float|null
  1978. */
  1979. public function getAdjustmentPositive()
  1980. {
  1981. return $this->getData(OrderInterface::ADJUSTMENT_POSITIVE);
  1982. }
  1983. /**
  1984. * Return applied_rule_ids
  1985. *
  1986. * Rules are comma separated if there are more than one.
  1987. *
  1988. * @return string|null
  1989. */
  1990. public function getAppliedRuleIds()
  1991. {
  1992. return $this->getData(OrderInterface::APPLIED_RULE_IDS);
  1993. }
  1994. /**
  1995. * Return base_adjustment_negative
  1996. *
  1997. * @return float|null
  1998. */
  1999. public function getBaseAdjustmentNegative()
  2000. {
  2001. return $this->getData(OrderInterface::BASE_ADJUSTMENT_NEGATIVE);
  2002. }
  2003. /**
  2004. * Return base_adjustment_positive
  2005. *
  2006. * @return float|null
  2007. */
  2008. public function getBaseAdjustmentPositive()
  2009. {
  2010. return $this->getData(OrderInterface::BASE_ADJUSTMENT_POSITIVE);
  2011. }
  2012. /**
  2013. * Return base_currency_code
  2014. *
  2015. * @return string|null
  2016. */
  2017. public function getBaseCurrencyCode()
  2018. {
  2019. return $this->getData(OrderInterface::BASE_CURRENCY_CODE);
  2020. }
  2021. /**
  2022. * Return base_discount_amount
  2023. *
  2024. * @return float|null
  2025. */
  2026. public function getBaseDiscountAmount()
  2027. {
  2028. return $this->getData(OrderInterface::BASE_DISCOUNT_AMOUNT);
  2029. }
  2030. /**
  2031. * Return base_discount_canceled
  2032. *
  2033. * @return float|null
  2034. */
  2035. public function getBaseDiscountCanceled()
  2036. {
  2037. return $this->getData(OrderInterface::BASE_DISCOUNT_CANCELED);
  2038. }
  2039. /**
  2040. * Return base_discount_invoiced
  2041. *
  2042. * @return float|null
  2043. */
  2044. public function getBaseDiscountInvoiced()
  2045. {
  2046. return $this->getData(OrderInterface::BASE_DISCOUNT_INVOICED);
  2047. }
  2048. /**
  2049. * Return base_discount_refunded
  2050. *
  2051. * @return float|null
  2052. */
  2053. public function getBaseDiscountRefunded()
  2054. {
  2055. return $this->getData(OrderInterface::BASE_DISCOUNT_REFUNDED);
  2056. }
  2057. /**
  2058. * Return base_grand_total
  2059. *
  2060. * @return float
  2061. */
  2062. public function getBaseGrandTotal()
  2063. {
  2064. return $this->getData(OrderInterface::BASE_GRAND_TOTAL);
  2065. }
  2066. /**
  2067. * Return base_discount_tax_compensation_amount
  2068. *
  2069. * @return float|null
  2070. */
  2071. public function getBaseDiscountTaxCompensationAmount()
  2072. {
  2073. return $this->getData(OrderInterface::BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT);
  2074. }
  2075. /**
  2076. * Return base_discount_tax_compensation_invoiced
  2077. *
  2078. * @return float|null
  2079. */
  2080. public function getBaseDiscountTaxCompensationInvoiced()
  2081. {
  2082. return $this->getData(OrderInterface::BASE_DISCOUNT_TAX_COMPENSATION_INVOICED);
  2083. }
  2084. /**
  2085. * Return base_discount_tax_compensation_refunded
  2086. *
  2087. * @return float|null
  2088. */
  2089. public function getBaseDiscountTaxCompensationRefunded()
  2090. {
  2091. return $this->getData(OrderInterface::BASE_DISCOUNT_TAX_COMPENSATION_REFUNDED);
  2092. }
  2093. /**
  2094. * Return base_shipping_amount
  2095. *
  2096. * @return float|null
  2097. */
  2098. public function getBaseShippingAmount()
  2099. {
  2100. return $this->getData(OrderInterface::BASE_SHIPPING_AMOUNT);
  2101. }
  2102. /**
  2103. * Return base_shipping_canceled
  2104. *
  2105. * @return float|null
  2106. */
  2107. public function getBaseShippingCanceled()
  2108. {
  2109. return $this->getData(OrderInterface::BASE_SHIPPING_CANCELED);
  2110. }
  2111. /**
  2112. * Return base_shipping_discount_amount
  2113. *
  2114. * @return float|null
  2115. */
  2116. public function getBaseShippingDiscountAmount()
  2117. {
  2118. return $this->getData(OrderInterface::BASE_SHIPPING_DISCOUNT_AMOUNT);
  2119. }
  2120. /**
  2121. * Return base_shipping_discount_tax_compensation_amnt
  2122. *
  2123. * @return float|null
  2124. */
  2125. public function getBaseShippingDiscountTaxCompensationAmnt()
  2126. {
  2127. return $this->getData(OrderInterface::BASE_SHIPPING_DISCOUNT_TAX_COMPENSATION_AMNT);
  2128. }
  2129. /**
  2130. * Return base_shipping_incl_tax
  2131. *
  2132. * @return float|null
  2133. */
  2134. public function getBaseShippingInclTax()
  2135. {
  2136. return $this->getData(OrderInterface::BASE_SHIPPING_INCL_TAX);
  2137. }
  2138. /**
  2139. * Return base_shipping_invoiced
  2140. *
  2141. * @return float|null
  2142. */
  2143. public function getBaseShippingInvoiced()
  2144. {
  2145. return $this->getData(OrderInterface::BASE_SHIPPING_INVOICED);
  2146. }
  2147. /**
  2148. * Return base_shipping_refunded
  2149. *
  2150. * @return float|null
  2151. */
  2152. public function getBaseShippingRefunded()
  2153. {
  2154. return $this->getData(OrderInterface::BASE_SHIPPING_REFUNDED);
  2155. }
  2156. /**
  2157. * Return base_shipping_tax_amount
  2158. *
  2159. * @return float|null
  2160. */
  2161. public function getBaseShippingTaxAmount()
  2162. {
  2163. return $this->getData(OrderInterface::BASE_SHIPPING_TAX_AMOUNT);
  2164. }
  2165. /**
  2166. * Return base_shipping_tax_refunded
  2167. *
  2168. * @return float|null
  2169. */
  2170. public function getBaseShippingTaxRefunded()
  2171. {
  2172. return $this->getData(OrderInterface::BASE_SHIPPING_TAX_REFUNDED);
  2173. }
  2174. /**
  2175. * Return base_subtotal
  2176. *
  2177. * @return float|null
  2178. */
  2179. public function getBaseSubtotal()
  2180. {
  2181. return $this->getData(OrderInterface::BASE_SUBTOTAL);
  2182. }
  2183. /**
  2184. * Return base_subtotal_canceled
  2185. *
  2186. * @return float|null
  2187. */
  2188. public function getBaseSubtotalCanceled()
  2189. {
  2190. return $this->getData(OrderInterface::BASE_SUBTOTAL_CANCELED);
  2191. }
  2192. /**
  2193. * Return base_subtotal_incl_tax
  2194. *
  2195. * @return float|null
  2196. */
  2197. public function getBaseSubtotalInclTax()
  2198. {
  2199. return $this->getData(OrderInterface::BASE_SUBTOTAL_INCL_TAX);
  2200. }
  2201. /**
  2202. * Return base_subtotal_invoiced
  2203. *
  2204. * @return float|null
  2205. */
  2206. public function getBaseSubtotalInvoiced()
  2207. {
  2208. return $this->getData(OrderInterface::BASE_SUBTOTAL_INVOICED);
  2209. }
  2210. /**
  2211. * Return base_subtotal_refunded
  2212. *
  2213. * @return float|null
  2214. */
  2215. public function getBaseSubtotalRefunded()
  2216. {
  2217. return $this->getData(OrderInterface::BASE_SUBTOTAL_REFUNDED);
  2218. }
  2219. /**
  2220. * Return base_tax_amount
  2221. *
  2222. * @return float|null
  2223. */
  2224. public function getBaseTaxAmount()
  2225. {
  2226. return $this->getData(OrderInterface::BASE_TAX_AMOUNT);
  2227. }
  2228. /**
  2229. * Return base_tax_canceled
  2230. *
  2231. * @return float|null
  2232. */
  2233. public function getBaseTaxCanceled()
  2234. {
  2235. return $this->getData(OrderInterface::BASE_TAX_CANCELED);
  2236. }
  2237. /**
  2238. * Return base_tax_invoiced
  2239. *
  2240. * @return float|null
  2241. */
  2242. public function getBaseTaxInvoiced()
  2243. {
  2244. return $this->getData(OrderInterface::BASE_TAX_INVOICED);
  2245. }
  2246. /**
  2247. * Return base_tax_refunded
  2248. *
  2249. * @return float|null
  2250. */
  2251. public function getBaseTaxRefunded()
  2252. {
  2253. return $this->getData(OrderInterface::BASE_TAX_REFUNDED);
  2254. }
  2255. /**
  2256. * Return base_total_canceled
  2257. *
  2258. * @return float|null
  2259. */
  2260. public function getBaseTotalCanceled()
  2261. {
  2262. return $this->getData(OrderInterface::BASE_TOTAL_CANCELED);
  2263. }
  2264. /**
  2265. * Return base_total_invoiced
  2266. *
  2267. * @return float|null
  2268. */
  2269. public function getBaseTotalInvoiced()
  2270. {
  2271. return $this->getData(OrderInterface::BASE_TOTAL_INVOICED);
  2272. }
  2273. /**
  2274. * Return base_total_invoiced_cost
  2275. *
  2276. * @return float|null
  2277. */
  2278. public function getBaseTotalInvoicedCost()
  2279. {
  2280. return $this->getData(OrderInterface::BASE_TOTAL_INVOICED_COST);
  2281. }
  2282. /**
  2283. * Return base_total_offline_refunded
  2284. *
  2285. * @return float|null
  2286. */
  2287. public function getBaseTotalOfflineRefunded()
  2288. {
  2289. return $this->getData(OrderInterface::BASE_TOTAL_OFFLINE_REFUNDED);
  2290. }
  2291. /**
  2292. * Return base_total_online_refunded
  2293. *
  2294. * @return float|null
  2295. */
  2296. public function getBaseTotalOnlineRefunded()
  2297. {
  2298. return $this->getData(OrderInterface::BASE_TOTAL_ONLINE_REFUNDED);
  2299. }
  2300. /**
  2301. * Return base_total_paid
  2302. *
  2303. * @return float|null
  2304. */
  2305. public function getBaseTotalPaid()
  2306. {
  2307. return $this->getData(OrderInterface::BASE_TOTAL_PAID);
  2308. }
  2309. /**
  2310. * Return base_total_qty_ordered
  2311. *
  2312. * @return float|null
  2313. */
  2314. public function getBaseTotalQtyOrdered()
  2315. {
  2316. return $this->getData(OrderInterface::BASE_TOTAL_QTY_ORDERED);
  2317. }
  2318. /**
  2319. * Return base_total_refunded
  2320. *
  2321. * @return float|null
  2322. */
  2323. public function getBaseTotalRefunded()
  2324. {
  2325. return $this->getData(OrderInterface::BASE_TOTAL_REFUNDED);
  2326. }
  2327. /**
  2328. * Return base_to_global_rate
  2329. *
  2330. * @return float|null
  2331. */
  2332. public function getBaseToGlobalRate()
  2333. {
  2334. return $this->getData(OrderInterface::BASE_TO_GLOBAL_RATE);
  2335. }
  2336. /**
  2337. * Return base_to_order_rate
  2338. *
  2339. * @return float|null
  2340. */
  2341. public function getBaseToOrderRate()
  2342. {
  2343. return $this->getData(OrderInterface::BASE_TO_ORDER_RATE);
  2344. }
  2345. /**
  2346. * Return billing_address_id
  2347. *
  2348. * @return int|null
  2349. */
  2350. public function getBillingAddressId()
  2351. {
  2352. return $this->getData(OrderInterface::BILLING_ADDRESS_ID);
  2353. }
  2354. /**
  2355. * Return can_ship_partially
  2356. *
  2357. * @return int|null
  2358. */
  2359. public function getCanShipPartially()
  2360. {
  2361. return $this->getData(OrderInterface::CAN_SHIP_PARTIALLY);
  2362. }
  2363. /**
  2364. * Return can_ship_partially_item
  2365. *
  2366. * @return int|null
  2367. */
  2368. public function getCanShipPartiallyItem()
  2369. {
  2370. return $this->getData(OrderInterface::CAN_SHIP_PARTIALLY_ITEM);
  2371. }
  2372. /**
  2373. * Return coupon_code
  2374. *
  2375. * @return string|null
  2376. */
  2377. public function getCouponCode()
  2378. {
  2379. return $this->getData(OrderInterface::COUPON_CODE);
  2380. }
  2381. /**
  2382. * Return created_at
  2383. *
  2384. * @return string|null
  2385. */
  2386. public function getCreatedAt()
  2387. {
  2388. return $this->getData(OrderInterface::CREATED_AT);
  2389. }
  2390. /**
  2391. * @inheritdoc
  2392. */
  2393. public function setCreatedAt($createdAt)
  2394. {
  2395. return $this->setData(OrderInterface::CREATED_AT, $createdAt);
  2396. }
  2397. /**
  2398. * Return customer_dob
  2399. *
  2400. * @return string|null
  2401. */
  2402. public function getCustomerDob()
  2403. {
  2404. return $this->getData(OrderInterface::CUSTOMER_DOB);
  2405. }
  2406. /**
  2407. * Return customer_email
  2408. *
  2409. * @return string
  2410. */
  2411. public function getCustomerEmail()
  2412. {
  2413. return $this->getData(OrderInterface::CUSTOMER_EMAIL);
  2414. }
  2415. /**
  2416. * Return customer_firstname
  2417. *
  2418. * @return string|null
  2419. */
  2420. public function getCustomerFirstname()
  2421. {
  2422. return $this->getData(OrderInterface::CUSTOMER_FIRSTNAME);
  2423. }
  2424. /**
  2425. * Return customer_gender
  2426. *
  2427. * @return int|null
  2428. */
  2429. public function getCustomerGender()
  2430. {
  2431. return $this->getData(OrderInterface::CUSTOMER_GENDER);
  2432. }
  2433. /**
  2434. * Return customer_group_id
  2435. *
  2436. * @return int|null
  2437. */
  2438. public function getCustomerGroupId()
  2439. {
  2440. return $this->getData(OrderInterface::CUSTOMER_GROUP_ID);
  2441. }
  2442. /**
  2443. * Return customer_id
  2444. *
  2445. * @return int|null
  2446. */
  2447. public function getCustomerId()
  2448. {
  2449. return $this->getData(OrderInterface::CUSTOMER_ID);
  2450. }
  2451. /**
  2452. * Return customer_is_guest
  2453. *
  2454. * @return int|null
  2455. */
  2456. public function getCustomerIsGuest()
  2457. {
  2458. return $this->getData(OrderInterface::CUSTOMER_IS_GUEST);
  2459. }
  2460. /**
  2461. * Return customer_lastname
  2462. *
  2463. * @return string|null
  2464. */
  2465. public function getCustomerLastname()
  2466. {
  2467. return $this->getData(OrderInterface::CUSTOMER_LASTNAME);
  2468. }
  2469. /**
  2470. * Return customer_middlename
  2471. *
  2472. * @return string|null
  2473. */
  2474. public function getCustomerMiddlename()
  2475. {
  2476. return $this->getData(OrderInterface::CUSTOMER_MIDDLENAME);
  2477. }
  2478. /**
  2479. * Return customer_note
  2480. *
  2481. * @return string|null
  2482. */
  2483. public function getCustomerNote()
  2484. {
  2485. return $this->getData(OrderInterface::CUSTOMER_NOTE);
  2486. }
  2487. /**
  2488. * Return customer_note_notify
  2489. *
  2490. * @return int|null
  2491. */
  2492. public function getCustomerNoteNotify()
  2493. {
  2494. return $this->getData(OrderInterface::CUSTOMER_NOTE_NOTIFY);
  2495. }
  2496. /**
  2497. * Return customer_prefix
  2498. *
  2499. * @return string|null
  2500. */
  2501. public function getCustomerPrefix()
  2502. {
  2503. return $this->getData(OrderInterface::CUSTOMER_PREFIX);
  2504. }
  2505. /**
  2506. * Return customer_suffix
  2507. *
  2508. * @return string|null
  2509. */
  2510. public function getCustomerSuffix()
  2511. {
  2512. return $this->getData(OrderInterface::CUSTOMER_SUFFIX);
  2513. }
  2514. /**
  2515. * Return customer_taxvat
  2516. *
  2517. * @return string|null
  2518. */
  2519. public function getCustomerTaxvat()
  2520. {
  2521. return $this->getData(OrderInterface::CUSTOMER_TAXVAT);
  2522. }
  2523. /**
  2524. * Return discount_amount
  2525. *
  2526. * @return float|null
  2527. */
  2528. public function getDiscountAmount()
  2529. {
  2530. return $this->getData(OrderInterface::DISCOUNT_AMOUNT);
  2531. }
  2532. /**
  2533. * Return discount_canceled
  2534. *
  2535. * @return float|null
  2536. */
  2537. public function getDiscountCanceled()
  2538. {
  2539. return $this->getData(OrderInterface::DISCOUNT_CANCELED);
  2540. }
  2541. /**
  2542. * Return discount_description
  2543. *
  2544. * @return string|null
  2545. */
  2546. public function getDiscountDescription()
  2547. {
  2548. return $this->getData(OrderInterface::DISCOUNT_DESCRIPTION);
  2549. }
  2550. /**
  2551. * Return discount_invoiced
  2552. *
  2553. * @return float|null
  2554. */
  2555. public function getDiscountInvoiced()
  2556. {
  2557. return $this->getData(OrderInterface::DISCOUNT_INVOICED);
  2558. }
  2559. /**
  2560. * Return discount_refunded
  2561. *
  2562. * @return float|null
  2563. */
  2564. public function getDiscountRefunded()
  2565. {
  2566. return $this->getData(OrderInterface::DISCOUNT_REFUNDED);
  2567. }
  2568. /**
  2569. * Return edit_increment
  2570. *
  2571. * @return int|null
  2572. */
  2573. public function getEditIncrement()
  2574. {
  2575. return $this->getData(OrderInterface::EDIT_INCREMENT);
  2576. }
  2577. /**
  2578. * Return email_sent
  2579. *
  2580. * @return int|null
  2581. */
  2582. public function getEmailSent()
  2583. {
  2584. return $this->getData(OrderInterface::EMAIL_SENT);
  2585. }
  2586. /**
  2587. * Return ext_customer_id
  2588. *
  2589. * @return string|null
  2590. */
  2591. public function getExtCustomerId()
  2592. {
  2593. return $this->getData(OrderInterface::EXT_CUSTOMER_ID);
  2594. }
  2595. /**
  2596. * Return ext_order_id
  2597. *
  2598. * @return string|null
  2599. */
  2600. public function getExtOrderId()
  2601. {
  2602. return $this->getData(OrderInterface::EXT_ORDER_ID);
  2603. }
  2604. /**
  2605. * Return forced_shipment_with_invoice
  2606. *
  2607. * @return int|null
  2608. */
  2609. public function getForcedShipmentWithInvoice()
  2610. {
  2611. return $this->getData(OrderInterface::FORCED_SHIPMENT_WITH_INVOICE);
  2612. }
  2613. /**
  2614. * Return global_currency_code
  2615. *
  2616. * @return string|null
  2617. */
  2618. public function getGlobalCurrencyCode()
  2619. {
  2620. return $this->getData(OrderInterface::GLOBAL_CURRENCY_CODE);
  2621. }
  2622. /**
  2623. * Return grand_total
  2624. *
  2625. * @return float
  2626. */
  2627. public function getGrandTotal()
  2628. {
  2629. return $this->getData(OrderInterface::GRAND_TOTAL);
  2630. }
  2631. /**
  2632. * Return discount_tax_compensation_amount
  2633. *
  2634. * @return float|null
  2635. */
  2636. public function getDiscountTaxCompensationAmount()
  2637. {
  2638. return $this->getData(OrderInterface::DISCOUNT_TAX_COMPENSATION_AMOUNT);
  2639. }
  2640. /**
  2641. * Return discount_tax_compensation_invoiced
  2642. *
  2643. * @return float|null
  2644. */
  2645. public function getDiscountTaxCompensationInvoiced()
  2646. {
  2647. return $this->getData(OrderInterface::DISCOUNT_TAX_COMPENSATION_INVOICED);
  2648. }
  2649. /**
  2650. * Return discount_tax_compensation_refunded
  2651. *
  2652. * @return float|null
  2653. */
  2654. public function getDiscountTaxCompensationRefunded()
  2655. {
  2656. return $this->getData(OrderInterface::DISCOUNT_TAX_COMPENSATION_REFUNDED);
  2657. }
  2658. /**
  2659. * Returns hold_before_state
  2660. *
  2661. * @return string|null
  2662. */
  2663. public function getHoldBeforeState()
  2664. {
  2665. return $this->getData(OrderInterface::HOLD_BEFORE_STATE);
  2666. }
  2667. /**
  2668. * Return hold_before_status
  2669. *
  2670. * @return string|null
  2671. */
  2672. public function getHoldBeforeStatus()
  2673. {
  2674. return $this->getData(OrderInterface::HOLD_BEFORE_STATUS);
  2675. }
  2676. /**
  2677. * Return is_virtual
  2678. *
  2679. * @return int|null
  2680. */
  2681. public function getIsVirtual()
  2682. {
  2683. return $this->getData(OrderInterface::IS_VIRTUAL);
  2684. }
  2685. /**
  2686. * Return order_currency_code
  2687. *
  2688. * @return string|null
  2689. */
  2690. public function getOrderCurrencyCode()
  2691. {
  2692. return $this->getData(OrderInterface::ORDER_CURRENCY_CODE);
  2693. }
  2694. /**
  2695. * Return original_increment_id
  2696. *
  2697. * @return string|null
  2698. */
  2699. public function getOriginalIncrementId()
  2700. {
  2701. return $this->getData(OrderInterface::ORIGINAL_INCREMENT_ID);
  2702. }
  2703. /**
  2704. * Return payment_authorization_amount
  2705. *
  2706. * @return float|null
  2707. */
  2708. public function getPaymentAuthorizationAmount()
  2709. {
  2710. return $this->getData(OrderInterface::PAYMENT_AUTHORIZATION_AMOUNT);
  2711. }
  2712. /**
  2713. * Return payment_auth_expiration
  2714. *
  2715. * @return int|null
  2716. */
  2717. public function getPaymentAuthExpiration()
  2718. {
  2719. return $this->getData(OrderInterface::PAYMENT_AUTH_EXPIRATION);
  2720. }
  2721. /**
  2722. * Return protect_code
  2723. *
  2724. * @return string|null
  2725. */
  2726. public function getProtectCode()
  2727. {
  2728. return $this->getData(OrderInterface::PROTECT_CODE);
  2729. }
  2730. /**
  2731. * Return quote_address_id
  2732. *
  2733. * @return int|null
  2734. */
  2735. public function getQuoteAddressId()
  2736. {
  2737. return $this->getData(OrderInterface::QUOTE_ADDRESS_ID);
  2738. }
  2739. /**
  2740. * Return quote_id
  2741. *
  2742. * @return int|null
  2743. */
  2744. public function getQuoteId()
  2745. {
  2746. return $this->getData(OrderInterface::QUOTE_ID);
  2747. }
  2748. /**
  2749. * Return relation_child_id
  2750. *
  2751. * @return string|null
  2752. */
  2753. public function getRelationChildId()
  2754. {
  2755. return $this->getData(OrderInterface::RELATION_CHILD_ID);
  2756. }
  2757. /**
  2758. * Return relation_child_real_id
  2759. *
  2760. * @return string|null
  2761. */
  2762. public function getRelationChildRealId()
  2763. {
  2764. return $this->getData(OrderInterface::RELATION_CHILD_REAL_ID);
  2765. }
  2766. /**
  2767. * Return relation_parent_id
  2768. *
  2769. * @return string|null
  2770. */
  2771. public function getRelationParentId()
  2772. {
  2773. return $this->getData(OrderInterface::RELATION_PARENT_ID);
  2774. }
  2775. /**
  2776. * Return relation_parent_real_id
  2777. *
  2778. * @return string|null
  2779. */
  2780. public function getRelationParentRealId()
  2781. {
  2782. return $this->getData(OrderInterface::RELATION_PARENT_REAL_ID);
  2783. }
  2784. /**
  2785. * Return remote_ip
  2786. *
  2787. * @return string|null
  2788. */
  2789. public function getRemoteIp()
  2790. {
  2791. return $this->getData(OrderInterface::REMOTE_IP);
  2792. }
  2793. /**
  2794. * Return shipping_amount
  2795. *
  2796. * @return float|null
  2797. */
  2798. public function getShippingAmount()
  2799. {
  2800. return $this->getData(OrderInterface::SHIPPING_AMOUNT);
  2801. }
  2802. /**
  2803. * Return shipping_canceled
  2804. *
  2805. * @return float|null
  2806. */
  2807. public function getShippingCanceled()
  2808. {
  2809. return $this->getData(OrderInterface::SHIPPING_CANCELED);
  2810. }
  2811. /**
  2812. * Return shipping_description
  2813. *
  2814. * @return string|null
  2815. */
  2816. public function getShippingDescription()
  2817. {
  2818. return $this->getData(OrderInterface::SHIPPING_DESCRIPTION);
  2819. }
  2820. /**
  2821. * Return shipping_discount_amount
  2822. *
  2823. * @return float|null
  2824. */
  2825. public function getShippingDiscountAmount()
  2826. {
  2827. return $this->getData(OrderInterface::SHIPPING_DISCOUNT_AMOUNT);
  2828. }
  2829. /**
  2830. * Return shipping_discount_tax_compensation_amount
  2831. *
  2832. * @return float|null
  2833. */
  2834. public function getShippingDiscountTaxCompensationAmount()
  2835. {
  2836. return $this->getData(OrderInterface::SHIPPING_DISCOUNT_TAX_COMPENSATION_AMOUNT);
  2837. }
  2838. /**
  2839. * Return shipping_incl_tax
  2840. *
  2841. * @return float|null
  2842. */
  2843. public function getShippingInclTax()
  2844. {
  2845. return $this->getData(OrderInterface::SHIPPING_INCL_TAX);
  2846. }
  2847. /**
  2848. * Return shipping_invoiced
  2849. *
  2850. * @return float|null
  2851. */
  2852. public function getShippingInvoiced()
  2853. {
  2854. return $this->getData(OrderInterface::SHIPPING_INVOICED);
  2855. }
  2856. /**
  2857. * Return shipping_refunded
  2858. *
  2859. * @return float|null
  2860. */
  2861. public function getShippingRefunded()
  2862. {
  2863. return $this->getData(OrderInterface::SHIPPING_REFUNDED);
  2864. }
  2865. /**
  2866. * Return shipping_tax_amount
  2867. *
  2868. * @return float|null
  2869. */
  2870. public function getShippingTaxAmount()
  2871. {
  2872. return $this->getData(OrderInterface::SHIPPING_TAX_AMOUNT);
  2873. }
  2874. /**
  2875. * Return shipping_tax_refunded
  2876. *
  2877. * @return float|null
  2878. */
  2879. public function getShippingTaxRefunded()
  2880. {
  2881. return $this->getData(OrderInterface::SHIPPING_TAX_REFUNDED);
  2882. }
  2883. /**
  2884. * Return state
  2885. *
  2886. * @return string|null
  2887. */
  2888. public function getState()
  2889. {
  2890. return $this->getData(OrderInterface::STATE);
  2891. }
  2892. /**
  2893. * Return status
  2894. *
  2895. * @return string|null
  2896. */
  2897. public function getStatus()
  2898. {
  2899. return $this->getData(OrderInterface::STATUS);
  2900. }
  2901. /**
  2902. * Return store_currency_code
  2903. *
  2904. * @return string|null
  2905. */
  2906. public function getStoreCurrencyCode()
  2907. {
  2908. return $this->getData(OrderInterface::STORE_CURRENCY_CODE);
  2909. }
  2910. /**
  2911. * Return store_id
  2912. *
  2913. * @return int|null
  2914. */
  2915. public function getStoreId()
  2916. {
  2917. return $this->getData(OrderInterface::STORE_ID);
  2918. }
  2919. /**
  2920. * Return store_name
  2921. *
  2922. * @return string|null
  2923. */
  2924. public function getStoreName()
  2925. {
  2926. return $this->getData(OrderInterface::STORE_NAME);
  2927. }
  2928. /**
  2929. * Return store_to_base_rate
  2930. *
  2931. * @return float|null
  2932. */
  2933. public function getStoreToBaseRate()
  2934. {
  2935. return $this->getData(OrderInterface::STORE_TO_BASE_RATE);
  2936. }
  2937. /**
  2938. * Return store_to_order_rate
  2939. *
  2940. * @return float|null
  2941. */
  2942. public function getStoreToOrderRate()
  2943. {
  2944. return $this->getData(OrderInterface::STORE_TO_ORDER_RATE);
  2945. }
  2946. /**
  2947. * Return subtotal
  2948. *
  2949. * @return float|null
  2950. */
  2951. public function getSubtotal()
  2952. {
  2953. return $this->getData(OrderInterface::SUBTOTAL);
  2954. }
  2955. /**
  2956. * Return subtotal_canceled
  2957. *
  2958. * @return float|null
  2959. */
  2960. public function getSubtotalCanceled()
  2961. {
  2962. return $this->getData(OrderInterface::SUBTOTAL_CANCELED);
  2963. }
  2964. /**
  2965. * Return subtotal_incl_tax
  2966. *
  2967. * @return float|null
  2968. */
  2969. public function getSubtotalInclTax()
  2970. {
  2971. return $this->getData(OrderInterface::SUBTOTAL_INCL_TAX);
  2972. }
  2973. /**
  2974. * Return subtotal_invoiced
  2975. *
  2976. * @return float|null
  2977. */
  2978. public function getSubtotalInvoiced()
  2979. {
  2980. return $this->getData(OrderInterface::SUBTOTAL_INVOICED);
  2981. }
  2982. /**
  2983. * Return subtotal_refunded
  2984. *
  2985. * @return float|null
  2986. */
  2987. public function getSubtotalRefunded()
  2988. {
  2989. return $this->getData(OrderInterface::SUBTOTAL_REFUNDED);
  2990. }
  2991. /**
  2992. * Return tax_amount
  2993. *
  2994. * @return float|null
  2995. */
  2996. public function getTaxAmount()
  2997. {
  2998. return $this->getData(OrderInterface::TAX_AMOUNT);
  2999. }
  3000. /**
  3001. * Return tax_canceled
  3002. *
  3003. * @return float|null
  3004. */
  3005. public function getTaxCanceled()
  3006. {
  3007. return $this->getData(OrderInterface::TAX_CANCELED);
  3008. }
  3009. /**
  3010. * Return tax_invoiced
  3011. *
  3012. * @return float|null
  3013. */
  3014. public function getTaxInvoiced()
  3015. {
  3016. return $this->getData(OrderInterface::TAX_INVOICED);
  3017. }
  3018. /**
  3019. * Return tax_refunded
  3020. *
  3021. * @return float|null
  3022. */
  3023. public function getTaxRefunded()
  3024. {
  3025. return $this->getData(OrderInterface::TAX_REFUNDED);
  3026. }
  3027. /**
  3028. * Return total_canceled
  3029. *
  3030. * @return float|null
  3031. */
  3032. public function getTotalCanceled()
  3033. {
  3034. return $this->getData(OrderInterface::TOTAL_CANCELED);
  3035. }
  3036. /**
  3037. * Return total_invoiced
  3038. *
  3039. * @return float|null
  3040. */
  3041. public function getTotalInvoiced()
  3042. {
  3043. return $this->getData(OrderInterface::TOTAL_INVOICED);
  3044. }
  3045. /**
  3046. * Return total_item_count
  3047. *
  3048. * @return int|null
  3049. */
  3050. public function getTotalItemCount()
  3051. {
  3052. return $this->getData(OrderInterface::TOTAL_ITEM_COUNT);
  3053. }
  3054. /**
  3055. * Return total_offline_refunded
  3056. *
  3057. * @return float|null
  3058. */
  3059. public function getTotalOfflineRefunded()
  3060. {
  3061. return $this->getData(OrderInterface::TOTAL_OFFLINE_REFUNDED);
  3062. }
  3063. /**
  3064. * Return total_online_refunded
  3065. *
  3066. * @return float|null
  3067. */
  3068. public function getTotalOnlineRefunded()
  3069. {
  3070. return $this->getData(OrderInterface::TOTAL_ONLINE_REFUNDED);
  3071. }
  3072. /**
  3073. * Return total_paid
  3074. *
  3075. * @return float|null
  3076. */
  3077. public function getTotalPaid()
  3078. {
  3079. return $this->getData(OrderInterface::TOTAL_PAID);
  3080. }
  3081. /**
  3082. * Return total_qty_ordered
  3083. *
  3084. * @return float|null
  3085. */
  3086. public function getTotalQtyOrdered()
  3087. {
  3088. return $this->getData(OrderInterface::TOTAL_QTY_ORDERED);
  3089. }
  3090. /**
  3091. * Return total_refunded
  3092. *
  3093. * @return float|null
  3094. */
  3095. public function getTotalRefunded()
  3096. {
  3097. return $this->getData(OrderInterface::TOTAL_REFUNDED);
  3098. }
  3099. /**
  3100. * Return updated_at
  3101. *
  3102. * @return string|null
  3103. */
  3104. public function getUpdatedAt()
  3105. {
  3106. return $this->getData(OrderInterface::UPDATED_AT);
  3107. }
  3108. /**
  3109. * Return weight
  3110. *
  3111. * @return float|null
  3112. */
  3113. public function getWeight()
  3114. {
  3115. return $this->getData(OrderInterface::WEIGHT);
  3116. }
  3117. /**
  3118. * Return x_forwarded_for
  3119. *
  3120. * @return string|null
  3121. */
  3122. public function getXForwardedFor()
  3123. {
  3124. return $this->getData(OrderInterface::X_FORWARDED_FOR);
  3125. }
  3126. /**
  3127. * @inheritdoc
  3128. */
  3129. public function setStatusHistories(array $statusHistories = null)
  3130. {
  3131. return $this->setData(OrderInterface::STATUS_HISTORIES, $statusHistories);
  3132. }
  3133. /**
  3134. * @inheritdoc
  3135. */
  3136. public function setStatus($status)
  3137. {
  3138. return $this->setData(OrderInterface::STATUS, $status);
  3139. }
  3140. /**
  3141. * @inheritdoc
  3142. */
  3143. public function setCouponCode($code)
  3144. {
  3145. return $this->setData(OrderInterface::COUPON_CODE, $code);
  3146. }
  3147. /**
  3148. * @inheritdoc
  3149. */
  3150. public function setProtectCode($code)
  3151. {
  3152. return $this->setData(OrderInterface::PROTECT_CODE, $code);
  3153. }
  3154. /**
  3155. * @inheritdoc
  3156. */
  3157. public function setShippingDescription($description)
  3158. {
  3159. return $this->setData(OrderInterface::SHIPPING_DESCRIPTION, $description);
  3160. }
  3161. /**
  3162. * @inheritdoc
  3163. */
  3164. public function setIsVirtual($isVirtual)
  3165. {
  3166. return $this->setData(OrderInterface::IS_VIRTUAL, $isVirtual);
  3167. }
  3168. /**
  3169. * @inheritdoc
  3170. */
  3171. public function setStoreId($id)
  3172. {
  3173. return $this->setData(OrderInterface::STORE_ID, $id);
  3174. }
  3175. /**
  3176. * @inheritdoc
  3177. */
  3178. public function setCustomerId($id)
  3179. {
  3180. return $this->setData(OrderInterface::CUSTOMER_ID, $id);
  3181. }
  3182. /**
  3183. * @inheritdoc
  3184. */
  3185. public function setBaseDiscountAmount($amount)
  3186. {
  3187. return $this->setData(OrderInterface::BASE_DISCOUNT_AMOUNT, $amount);
  3188. }
  3189. /**
  3190. * @inheritdoc
  3191. */
  3192. public function setBaseDiscountCanceled($baseDiscountCanceled)
  3193. {
  3194. return $this->setData(OrderInterface::BASE_DISCOUNT_CANCELED, $baseDiscountCanceled);
  3195. }
  3196. /**
  3197. * @inheritdoc
  3198. */
  3199. public function setBaseDiscountInvoiced($baseDiscountInvoiced)
  3200. {
  3201. return $this->setData(OrderInterface::BASE_DISCOUNT_INVOICED, $baseDiscountInvoiced);
  3202. }
  3203. /**
  3204. * @inheritdoc
  3205. */
  3206. public function setBaseDiscountRefunded($baseDiscountRefunded)
  3207. {
  3208. return $this->setData(OrderInterface::BASE_DISCOUNT_REFUNDED, $baseDiscountRefunded);
  3209. }
  3210. /**
  3211. * @inheritdoc
  3212. */
  3213. public function setBaseGrandTotal($amount)
  3214. {
  3215. return $this->setData(OrderInterface::BASE_GRAND_TOTAL, $amount);
  3216. }
  3217. /**
  3218. * @inheritdoc
  3219. */
  3220. public function setBaseShippingAmount($amount)
  3221. {
  3222. return $this->setData(OrderInterface::BASE_SHIPPING_AMOUNT, $amount);
  3223. }
  3224. /**
  3225. * @inheritdoc
  3226. */
  3227. public function setBaseShippingCanceled($baseShippingCanceled)
  3228. {
  3229. return $this->setData(OrderInterface::BASE_SHIPPING_CANCELED, $baseShippingCanceled);
  3230. }
  3231. /**
  3232. * @inheritdoc
  3233. */
  3234. public function setBaseShippingInvoiced($baseShippingInvoiced)
  3235. {
  3236. return $this->setData(OrderInterface::BASE_SHIPPING_INVOICED, $baseShippingInvoiced);
  3237. }
  3238. /**
  3239. * @inheritdoc
  3240. */
  3241. public function setBaseShippingRefunded($baseShippingRefunded)
  3242. {
  3243. return $this->setData(OrderInterface::BASE_SHIPPING_REFUNDED, $baseShippingRefunded);
  3244. }
  3245. /**
  3246. * @inheritdoc
  3247. */
  3248. public function setBaseShippingTaxAmount($amount)
  3249. {
  3250. return $this->setData(OrderInterface::BASE_SHIPPING_TAX_AMOUNT, $amount);
  3251. }
  3252. /**
  3253. * @inheritdoc
  3254. */
  3255. public function setBaseShippingTaxRefunded($baseShippingTaxRefunded)
  3256. {
  3257. return $this->setData(OrderInterface::BASE_SHIPPING_TAX_REFUNDED, $baseShippingTaxRefunded);
  3258. }
  3259. /**
  3260. * @inheritdoc
  3261. */
  3262. public function setBaseSubtotal($amount)
  3263. {
  3264. return $this->setData(OrderInterface::BASE_SUBTOTAL, $amount);
  3265. }
  3266. /**
  3267. * @inheritdoc
  3268. */
  3269. public function setBaseSubtotalCanceled($baseSubtotalCanceled)
  3270. {
  3271. return $this->setData(OrderInterface::BASE_SUBTOTAL_CANCELED, $baseSubtotalCanceled);
  3272. }
  3273. /**
  3274. * @inheritdoc
  3275. */
  3276. public function setBaseSubtotalInvoiced($baseSubtotalInvoiced)
  3277. {
  3278. return $this->setData(OrderInterface::BASE_SUBTOTAL_INVOICED, $baseSubtotalInvoiced);
  3279. }
  3280. /**
  3281. * @inheritdoc
  3282. */
  3283. public function setBaseSubtotalRefunded($baseSubtotalRefunded)
  3284. {
  3285. return $this->setData(OrderInterface::BASE_SUBTOTAL_REFUNDED, $baseSubtotalRefunded);
  3286. }
  3287. /**
  3288. * @inheritdoc
  3289. */
  3290. public function setBaseTaxAmount($amount)
  3291. {
  3292. return $this->setData(OrderInterface::BASE_TAX_AMOUNT, $amount);
  3293. }
  3294. /**
  3295. * @inheritdoc
  3296. */
  3297. public function setBaseTaxCanceled($baseTaxCanceled)
  3298. {
  3299. return $this->setData(OrderInterface::BASE_TAX_CANCELED, $baseTaxCanceled);
  3300. }
  3301. /**
  3302. * @inheritdoc
  3303. */
  3304. public function setBaseTaxInvoiced($baseTaxInvoiced)
  3305. {
  3306. return $this->setData(OrderInterface::BASE_TAX_INVOICED, $baseTaxInvoiced);
  3307. }
  3308. /**
  3309. * @inheritdoc
  3310. */
  3311. public function setBaseTaxRefunded($baseTaxRefunded)
  3312. {
  3313. return $this->setData(OrderInterface::BASE_TAX_REFUNDED, $baseTaxRefunded);
  3314. }
  3315. /**
  3316. * @inheritdoc
  3317. */
  3318. public function setBaseToGlobalRate($rate)
  3319. {
  3320. return $this->setData(OrderInterface::BASE_TO_GLOBAL_RATE, $rate);
  3321. }
  3322. /**
  3323. * @inheritdoc
  3324. */
  3325. public function setBaseToOrderRate($rate)
  3326. {
  3327. return $this->setData(OrderInterface::BASE_TO_ORDER_RATE, $rate);
  3328. }
  3329. /**
  3330. * @inheritdoc
  3331. */
  3332. public function setBaseTotalCanceled($baseTotalCanceled)
  3333. {
  3334. return $this->setData(OrderInterface::BASE_TOTAL_CANCELED, $baseTotalCanceled);
  3335. }
  3336. /**
  3337. * @inheritdoc
  3338. */
  3339. public function setBaseTotalInvoiced($baseTotalInvoiced)
  3340. {
  3341. return $this->setData(OrderInterface::BASE_TOTAL_INVOICED, $baseTotalInvoiced);
  3342. }
  3343. /**
  3344. * @inheritdoc
  3345. */
  3346. public function setBaseTotalInvoicedCost($baseTotalInvoicedCost)
  3347. {
  3348. return $this->setData(OrderInterface::BASE_TOTAL_INVOICED_COST, $baseTotalInvoicedCost);
  3349. }
  3350. /**
  3351. * @inheritdoc
  3352. */
  3353. public function setBaseTotalOfflineRefunded($baseTotalOfflineRefunded)
  3354. {
  3355. return $this->setData(OrderInterface::BASE_TOTAL_OFFLINE_REFUNDED, $baseTotalOfflineRefunded);
  3356. }
  3357. /**
  3358. * @inheritdoc
  3359. */
  3360. public function setBaseTotalOnlineRefunded($baseTotalOnlineRefunded)
  3361. {
  3362. return $this->setData(OrderInterface::BASE_TOTAL_ONLINE_REFUNDED, $baseTotalOnlineRefunded);
  3363. }
  3364. /**
  3365. * @inheritdoc
  3366. */
  3367. public function setBaseTotalPaid($baseTotalPaid)
  3368. {
  3369. return $this->setData(OrderInterface::BASE_TOTAL_PAID, $baseTotalPaid);
  3370. }
  3371. /**
  3372. * @inheritdoc
  3373. */
  3374. public function setBaseTotalQtyOrdered($baseTotalQtyOrdered)
  3375. {
  3376. return $this->setData(OrderInterface::BASE_TOTAL_QTY_ORDERED, $baseTotalQtyOrdered);
  3377. }
  3378. /**
  3379. * @inheritdoc
  3380. */
  3381. public function setBaseTotalRefunded($baseTotalRefunded)
  3382. {
  3383. return $this->setData(OrderInterface::BASE_TOTAL_REFUNDED, $baseTotalRefunded);
  3384. }
  3385. /**
  3386. * @inheritdoc
  3387. */
  3388. public function setDiscountAmount($amount)
  3389. {
  3390. return $this->setData(OrderInterface::DISCOUNT_AMOUNT, $amount);
  3391. }
  3392. /**
  3393. * @inheritdoc
  3394. */
  3395. public function setDiscountCanceled($discountCanceled)
  3396. {
  3397. return $this->setData(OrderInterface::DISCOUNT_CANCELED, $discountCanceled);
  3398. }
  3399. /**
  3400. * @inheritdoc
  3401. */
  3402. public function setDiscountInvoiced($discountInvoiced)
  3403. {
  3404. return $this->setData(OrderInterface::DISCOUNT_INVOICED, $discountInvoiced);
  3405. }
  3406. /**
  3407. * @inheritdoc
  3408. */
  3409. public function setDiscountRefunded($discountRefunded)
  3410. {
  3411. return $this->setData(OrderInterface::DISCOUNT_REFUNDED, $discountRefunded);
  3412. }
  3413. /**
  3414. * @inheritdoc
  3415. */
  3416. public function setGrandTotal($amount)
  3417. {
  3418. return $this->setData(OrderInterface::GRAND_TOTAL, $amount);
  3419. }
  3420. /**
  3421. * @inheritdoc
  3422. */
  3423. public function setShippingAmount($amount)
  3424. {
  3425. return $this->setData(OrderInterface::SHIPPING_AMOUNT, $amount);
  3426. }
  3427. /**
  3428. * @inheritdoc
  3429. */
  3430. public function setShippingCanceled($shippingCanceled)
  3431. {
  3432. return $this->setData(OrderInterface::SHIPPING_CANCELED, $shippingCanceled);
  3433. }
  3434. /**
  3435. * @inheritdoc
  3436. */
  3437. public function setShippingInvoiced($shippingInvoiced)
  3438. {
  3439. return $this->setData(OrderInterface::SHIPPING_INVOICED, $shippingInvoiced);
  3440. }
  3441. /**
  3442. * @inheritdoc
  3443. */
  3444. public function setShippingRefunded($shippingRefunded)
  3445. {
  3446. return $this->setData(OrderInterface::SHIPPING_REFUNDED, $shippingRefunded);
  3447. }
  3448. /**
  3449. * @inheritdoc
  3450. */
  3451. public function setShippingTaxAmount($amount)
  3452. {
  3453. return $this->setData(OrderInterface::SHIPPING_TAX_AMOUNT, $amount);
  3454. }
  3455. /**
  3456. * @inheritdoc
  3457. */
  3458. public function setShippingTaxRefunded($shippingTaxRefunded)
  3459. {
  3460. return $this->setData(OrderInterface::SHIPPING_TAX_REFUNDED, $shippingTaxRefunded);
  3461. }
  3462. /**
  3463. * @inheritdoc
  3464. */
  3465. public function setStoreToBaseRate($rate)
  3466. {
  3467. return $this->setData(OrderInterface::STORE_TO_BASE_RATE, $rate);
  3468. }
  3469. /**
  3470. * @inheritdoc
  3471. */
  3472. public function setStoreToOrderRate($rate)
  3473. {
  3474. return $this->setData(OrderInterface::STORE_TO_ORDER_RATE, $rate);
  3475. }
  3476. /**
  3477. * @inheritdoc
  3478. */
  3479. public function setSubtotal($amount)
  3480. {
  3481. return $this->setData(OrderInterface::SUBTOTAL, $amount);
  3482. }
  3483. /**
  3484. * @inheritdoc
  3485. */
  3486. public function setSubtotalCanceled($subtotalCanceled)
  3487. {
  3488. return $this->setData(OrderInterface::SUBTOTAL_CANCELED, $subtotalCanceled);
  3489. }
  3490. /**
  3491. * @inheritdoc
  3492. */
  3493. public function setSubtotalInvoiced($subtotalInvoiced)
  3494. {
  3495. return $this->setData(OrderInterface::SUBTOTAL_INVOICED, $subtotalInvoiced);
  3496. }
  3497. /**
  3498. * @inheritdoc
  3499. */
  3500. public function setSubtotalRefunded($subtotalRefunded)
  3501. {
  3502. return $this->setData(OrderInterface::SUBTOTAL_REFUNDED, $subtotalRefunded);
  3503. }
  3504. /**
  3505. * @inheritdoc
  3506. */
  3507. public function setTaxAmount($amount)
  3508. {
  3509. return $this->setData(OrderInterface::TAX_AMOUNT, $amount);
  3510. }
  3511. /**
  3512. * @inheritdoc
  3513. */
  3514. public function setTaxCanceled($taxCanceled)
  3515. {
  3516. return $this->setData(OrderInterface::TAX_CANCELED, $taxCanceled);
  3517. }
  3518. /**
  3519. * @inheritdoc
  3520. */
  3521. public function setTaxInvoiced($taxInvoiced)
  3522. {
  3523. return $this->setData(OrderInterface::TAX_INVOICED, $taxInvoiced);
  3524. }
  3525. /**
  3526. * @inheritdoc
  3527. */
  3528. public function setTaxRefunded($taxRefunded)
  3529. {
  3530. return $this->setData(OrderInterface::TAX_REFUNDED, $taxRefunded);
  3531. }
  3532. /**
  3533. * @inheritdoc
  3534. */
  3535. public function setTotalCanceled($totalCanceled)
  3536. {
  3537. return $this->setData(OrderInterface::TOTAL_CANCELED, $totalCanceled);
  3538. }
  3539. /**
  3540. * @inheritdoc
  3541. */
  3542. public function setTotalInvoiced($totalInvoiced)
  3543. {
  3544. return $this->setData(OrderInterface::TOTAL_INVOICED, $totalInvoiced);
  3545. }
  3546. /**
  3547. * @inheritdoc
  3548. */
  3549. public function setTotalOfflineRefunded($totalOfflineRefunded)
  3550. {
  3551. return $this->setData(OrderInterface::TOTAL_OFFLINE_REFUNDED, $totalOfflineRefunded);
  3552. }
  3553. /**
  3554. * @inheritdoc
  3555. */
  3556. public function setTotalOnlineRefunded($totalOnlineRefunded)
  3557. {
  3558. return $this->setData(OrderInterface::TOTAL_ONLINE_REFUNDED, $totalOnlineRefunded);
  3559. }
  3560. /**
  3561. * @inheritdoc
  3562. */
  3563. public function setTotalPaid($totalPaid)
  3564. {
  3565. return $this->setData(OrderInterface::TOTAL_PAID, $totalPaid);
  3566. }
  3567. /**
  3568. * @inheritdoc
  3569. */
  3570. public function setTotalQtyOrdered($totalQtyOrdered)
  3571. {
  3572. return $this->setData(OrderInterface::TOTAL_QTY_ORDERED, $totalQtyOrdered);
  3573. }
  3574. /**
  3575. * @inheritdoc
  3576. */
  3577. public function setTotalRefunded($totalRefunded)
  3578. {
  3579. return $this->setData(OrderInterface::TOTAL_REFUNDED, $totalRefunded);
  3580. }
  3581. /**
  3582. * @inheritdoc
  3583. */
  3584. public function setCanShipPartially($flag)
  3585. {
  3586. return $this->setData(OrderInterface::CAN_SHIP_PARTIALLY, $flag);
  3587. }
  3588. /**
  3589. * @inheritdoc
  3590. */
  3591. public function setCanShipPartiallyItem($flag)
  3592. {
  3593. return $this->setData(OrderInterface::CAN_SHIP_PARTIALLY_ITEM, $flag);
  3594. }
  3595. /**
  3596. * @inheritdoc
  3597. */
  3598. public function setCustomerIsGuest($customerIsGuest)
  3599. {
  3600. return $this->setData(OrderInterface::CUSTOMER_IS_GUEST, $customerIsGuest);
  3601. }
  3602. /**
  3603. * @inheritdoc
  3604. */
  3605. public function setCustomerNoteNotify($customerNoteNotify)
  3606. {
  3607. return $this->setData(OrderInterface::CUSTOMER_NOTE_NOTIFY, $customerNoteNotify);
  3608. }
  3609. /**
  3610. * @inheritdoc
  3611. */
  3612. public function setBillingAddressId($id)
  3613. {
  3614. return $this->setData(OrderInterface::BILLING_ADDRESS_ID, $id);
  3615. }
  3616. /**
  3617. * @inheritdoc
  3618. */
  3619. public function setCustomerGroupId($id)
  3620. {
  3621. return $this->setData(OrderInterface::CUSTOMER_GROUP_ID, $id);
  3622. }
  3623. /**
  3624. * @inheritdoc
  3625. */
  3626. public function setEditIncrement($editIncrement)
  3627. {
  3628. return $this->setData(OrderInterface::EDIT_INCREMENT, $editIncrement);
  3629. }
  3630. /**
  3631. * @inheritdoc
  3632. */
  3633. public function setEmailSent($emailSent)
  3634. {
  3635. return $this->setData(OrderInterface::EMAIL_SENT, $emailSent);
  3636. }
  3637. /**
  3638. * @inheritdoc
  3639. */
  3640. public function setForcedShipmentWithInvoice($forcedShipmentWithInvoice)
  3641. {
  3642. return $this->setData(OrderInterface::FORCED_SHIPMENT_WITH_INVOICE, $forcedShipmentWithInvoice);
  3643. }
  3644. /**
  3645. * @inheritdoc
  3646. */
  3647. public function setPaymentAuthExpiration($paymentAuthExpiration)
  3648. {
  3649. return $this->setData(OrderInterface::PAYMENT_AUTH_EXPIRATION, $paymentAuthExpiration);
  3650. }
  3651. /**
  3652. * @inheritdoc
  3653. */
  3654. public function setQuoteAddressId($id)
  3655. {
  3656. return $this->setData(OrderInterface::QUOTE_ADDRESS_ID, $id);
  3657. }
  3658. /**
  3659. * @inheritdoc
  3660. */
  3661. public function setQuoteId($id)
  3662. {
  3663. return $this->setData(OrderInterface::QUOTE_ID, $id);
  3664. }
  3665. /**
  3666. * @inheritdoc
  3667. */
  3668. public function setAdjustmentNegative($adjustmentNegative)
  3669. {
  3670. return $this->setData(OrderInterface::ADJUSTMENT_NEGATIVE, $adjustmentNegative);
  3671. }
  3672. /**
  3673. * @inheritdoc
  3674. */
  3675. public function setAdjustmentPositive($adjustmentPositive)
  3676. {
  3677. return $this->setData(OrderInterface::ADJUSTMENT_POSITIVE, $adjustmentPositive);
  3678. }
  3679. /**
  3680. * @inheritdoc
  3681. */
  3682. public function setBaseAdjustmentNegative($baseAdjustmentNegative)
  3683. {
  3684. return $this->setData(OrderInterface::BASE_ADJUSTMENT_NEGATIVE, $baseAdjustmentNegative);
  3685. }
  3686. /**
  3687. * @inheritdoc
  3688. */
  3689. public function setBaseAdjustmentPositive($baseAdjustmentPositive)
  3690. {
  3691. return $this->setData(OrderInterface::BASE_ADJUSTMENT_POSITIVE, $baseAdjustmentPositive);
  3692. }
  3693. /**
  3694. * @inheritdoc
  3695. */
  3696. public function setBaseShippingDiscountAmount($amount)
  3697. {
  3698. return $this->setData(OrderInterface::BASE_SHIPPING_DISCOUNT_AMOUNT, $amount);
  3699. }
  3700. /**
  3701. * @inheritdoc
  3702. */
  3703. public function setBaseSubtotalInclTax($amount)
  3704. {
  3705. return $this->setData(OrderInterface::BASE_SUBTOTAL_INCL_TAX, $amount);
  3706. }
  3707. /**
  3708. * @inheritdoc
  3709. */
  3710. public function setBaseTotalDue($baseTotalDue)
  3711. {
  3712. return $this->setData(OrderInterface::BASE_TOTAL_DUE, $baseTotalDue);
  3713. }
  3714. /**
  3715. * @inheritdoc
  3716. */
  3717. public function setPaymentAuthorizationAmount($amount)
  3718. {
  3719. return $this->setData(OrderInterface::PAYMENT_AUTHORIZATION_AMOUNT, $amount);
  3720. }
  3721. /**
  3722. * @inheritdoc
  3723. */
  3724. public function setShippingDiscountAmount($amount)
  3725. {
  3726. return $this->setData(OrderInterface::SHIPPING_DISCOUNT_AMOUNT, $amount);
  3727. }
  3728. /**
  3729. * @inheritdoc
  3730. */
  3731. public function setSubtotalInclTax($amount)
  3732. {
  3733. return $this->setData(OrderInterface::SUBTOTAL_INCL_TAX, $amount);
  3734. }
  3735. /**
  3736. * @inheritdoc
  3737. */
  3738. public function setTotalDue($totalDue)
  3739. {
  3740. return $this->setData(OrderInterface::TOTAL_DUE, $totalDue);
  3741. }
  3742. /**
  3743. * @inheritdoc
  3744. */
  3745. public function setWeight($weight)
  3746. {
  3747. return $this->setData(OrderInterface::WEIGHT, $weight);
  3748. }
  3749. /**
  3750. * @inheritdoc
  3751. */
  3752. public function setCustomerDob($customerDob)
  3753. {
  3754. return $this->setData(OrderInterface::CUSTOMER_DOB, $customerDob);
  3755. }
  3756. /**
  3757. * @inheritdoc
  3758. */
  3759. public function setIncrementId($id)
  3760. {
  3761. return $this->setData(OrderInterface::INCREMENT_ID, $id);
  3762. }
  3763. /**
  3764. * @inheritdoc
  3765. */
  3766. public function setAppliedRuleIds($appliedRuleIds)
  3767. {
  3768. return $this->setData(OrderInterface::APPLIED_RULE_IDS, $appliedRuleIds);
  3769. }
  3770. /**
  3771. * @inheritdoc
  3772. */
  3773. public function setBaseCurrencyCode($code)
  3774. {
  3775. return $this->setData(OrderInterface::BASE_CURRENCY_CODE, $code);
  3776. }
  3777. /**
  3778. * @inheritdoc
  3779. */
  3780. public function setCustomerEmail($customerEmail)
  3781. {
  3782. return $this->setData(OrderInterface::CUSTOMER_EMAIL, $customerEmail);
  3783. }
  3784. /**
  3785. * @inheritdoc
  3786. */
  3787. public function setCustomerFirstname($customerFirstname)
  3788. {
  3789. return $this->setData(OrderInterface::CUSTOMER_FIRSTNAME, $customerFirstname);
  3790. }
  3791. /**
  3792. * @inheritdoc
  3793. */
  3794. public function setCustomerLastname($customerLastname)
  3795. {
  3796. return $this->setData(OrderInterface::CUSTOMER_LASTNAME, $customerLastname);
  3797. }
  3798. /**
  3799. * @inheritdoc
  3800. */
  3801. public function setCustomerMiddlename($customerMiddlename)
  3802. {
  3803. return $this->setData(OrderInterface::CUSTOMER_MIDDLENAME, $customerMiddlename);
  3804. }
  3805. /**
  3806. * @inheritdoc
  3807. */
  3808. public function setCustomerPrefix($customerPrefix)
  3809. {
  3810. return $this->setData(OrderInterface::CUSTOMER_PREFIX, $customerPrefix);
  3811. }
  3812. /**
  3813. * @inheritdoc
  3814. */
  3815. public function setCustomerSuffix($customerSuffix)
  3816. {
  3817. return $this->setData(OrderInterface::CUSTOMER_SUFFIX, $customerSuffix);
  3818. }
  3819. /**
  3820. * @inheritdoc
  3821. */
  3822. public function setCustomerTaxvat($customerTaxvat)
  3823. {
  3824. return $this->setData(OrderInterface::CUSTOMER_TAXVAT, $customerTaxvat);
  3825. }
  3826. /**
  3827. * @inheritdoc
  3828. */
  3829. public function setDiscountDescription($description)
  3830. {
  3831. return $this->setData(OrderInterface::DISCOUNT_DESCRIPTION, $description);
  3832. }
  3833. /**
  3834. * @inheritdoc
  3835. */
  3836. public function setExtCustomerId($id)
  3837. {
  3838. return $this->setData(OrderInterface::EXT_CUSTOMER_ID, $id);
  3839. }
  3840. /**
  3841. * @inheritdoc
  3842. */
  3843. public function setExtOrderId($id)
  3844. {
  3845. return $this->setData(OrderInterface::EXT_ORDER_ID, $id);
  3846. }
  3847. /**
  3848. * @inheritdoc
  3849. */
  3850. public function setGlobalCurrencyCode($code)
  3851. {
  3852. return $this->setData(OrderInterface::GLOBAL_CURRENCY_CODE, $code);
  3853. }
  3854. /**
  3855. * @inheritdoc
  3856. */
  3857. public function setHoldBeforeState($holdBeforeState)
  3858. {
  3859. return $this->setData(OrderInterface::HOLD_BEFORE_STATE, $holdBeforeState);
  3860. }
  3861. /**
  3862. * @inheritdoc
  3863. */
  3864. public function setHoldBeforeStatus($holdBeforeStatus)
  3865. {
  3866. return $this->setData(OrderInterface::HOLD_BEFORE_STATUS, $holdBeforeStatus);
  3867. }
  3868. /**
  3869. * @inheritdoc
  3870. */
  3871. public function setOrderCurrencyCode($code)
  3872. {
  3873. return $this->setData(OrderInterface::ORDER_CURRENCY_CODE, $code);
  3874. }
  3875. /**
  3876. * @inheritdoc
  3877. */
  3878. public function setOriginalIncrementId($id)
  3879. {
  3880. return $this->setData(OrderInterface::ORIGINAL_INCREMENT_ID, $id);
  3881. }
  3882. /**
  3883. * @inheritdoc
  3884. */
  3885. public function setRelationChildId($id)
  3886. {
  3887. return $this->setData(OrderInterface::RELATION_CHILD_ID, $id);
  3888. }
  3889. /**
  3890. * @inheritdoc
  3891. */
  3892. public function setRelationChildRealId($realId)
  3893. {
  3894. return $this->setData(OrderInterface::RELATION_CHILD_REAL_ID, $realId);
  3895. }
  3896. /**
  3897. * @inheritdoc
  3898. */
  3899. public function setRelationParentId($id)
  3900. {
  3901. return $this->setData(OrderInterface::RELATION_PARENT_ID, $id);
  3902. }
  3903. /**
  3904. * @inheritdoc
  3905. */
  3906. public function setRelationParentRealId($realId)
  3907. {
  3908. return $this->setData(OrderInterface::RELATION_PARENT_REAL_ID, $realId);
  3909. }
  3910. /**
  3911. * @inheritdoc
  3912. */
  3913. public function setRemoteIp($remoteIp)
  3914. {
  3915. return $this->setData(OrderInterface::REMOTE_IP, $remoteIp);
  3916. }
  3917. /**
  3918. * @inheritdoc
  3919. */
  3920. public function setStoreCurrencyCode($code)
  3921. {
  3922. return $this->setData(OrderInterface::STORE_CURRENCY_CODE, $code);
  3923. }
  3924. /**
  3925. * @inheritdoc
  3926. */
  3927. public function setStoreName($storeName)
  3928. {
  3929. return $this->setData(OrderInterface::STORE_NAME, $storeName);
  3930. }
  3931. /**
  3932. * @inheritdoc
  3933. */
  3934. public function setXForwardedFor($xForwardedFor)
  3935. {
  3936. return $this->setData(OrderInterface::X_FORWARDED_FOR, $xForwardedFor);
  3937. }
  3938. /**
  3939. * @inheritdoc
  3940. */
  3941. public function setCustomerNote($customerNote)
  3942. {
  3943. return $this->setData(OrderInterface::CUSTOMER_NOTE, $customerNote);
  3944. }
  3945. /**
  3946. * @inheritdoc
  3947. */
  3948. public function setUpdatedAt($timestamp)
  3949. {
  3950. return $this->setData(OrderInterface::UPDATED_AT, $timestamp);
  3951. }
  3952. /**
  3953. * @inheritdoc
  3954. */
  3955. public function setTotalItemCount($totalItemCount)
  3956. {
  3957. return $this->setData(OrderInterface::TOTAL_ITEM_COUNT, $totalItemCount);
  3958. }
  3959. /**
  3960. * @inheritdoc
  3961. */
  3962. public function setCustomerGender($customerGender)
  3963. {
  3964. return $this->setData(OrderInterface::CUSTOMER_GENDER, $customerGender);
  3965. }
  3966. /**
  3967. * @inheritdoc
  3968. */
  3969. public function setDiscountTaxCompensationAmount($amount)
  3970. {
  3971. return $this->setData(OrderInterface::DISCOUNT_TAX_COMPENSATION_AMOUNT, $amount);
  3972. }
  3973. /**
  3974. * @inheritdoc
  3975. */
  3976. public function setBaseDiscountTaxCompensationAmount($amount)
  3977. {
  3978. return $this->setData(OrderInterface::BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT, $amount);
  3979. }
  3980. /**
  3981. * @inheritdoc
  3982. */
  3983. public function setShippingDiscountTaxCompensationAmount($amount)
  3984. {
  3985. return $this->setData(OrderInterface::SHIPPING_DISCOUNT_TAX_COMPENSATION_AMOUNT, $amount);
  3986. }
  3987. /**
  3988. * @inheritdoc
  3989. */
  3990. public function setBaseShippingDiscountTaxCompensationAmnt($amnt)
  3991. {
  3992. return $this->setData(OrderInterface::BASE_SHIPPING_DISCOUNT_TAX_COMPENSATION_AMNT, $amnt);
  3993. }
  3994. /**
  3995. * @inheritdoc
  3996. */
  3997. public function setDiscountTaxCompensationInvoiced($discountTaxCompensationInvoiced)
  3998. {
  3999. return $this->setData(OrderInterface::DISCOUNT_TAX_COMPENSATION_INVOICED, $discountTaxCompensationInvoiced);
  4000. }
  4001. /**
  4002. * @inheritdoc
  4003. */
  4004. public function setBaseDiscountTaxCompensationInvoiced($baseDiscountTaxCompensationInvoiced)
  4005. {
  4006. return $this->setData(
  4007. OrderInterface::BASE_DISCOUNT_TAX_COMPENSATION_INVOICED,
  4008. $baseDiscountTaxCompensationInvoiced
  4009. );
  4010. }
  4011. /**
  4012. * @inheritdoc
  4013. */
  4014. public function setDiscountTaxCompensationRefunded($discountTaxCompensationRefunded)
  4015. {
  4016. return $this->setData(
  4017. OrderInterface::DISCOUNT_TAX_COMPENSATION_REFUNDED,
  4018. $discountTaxCompensationRefunded
  4019. );
  4020. }
  4021. /**
  4022. * @inheritdoc
  4023. */
  4024. public function setBaseDiscountTaxCompensationRefunded($baseDiscountTaxCompensationRefunded)
  4025. {
  4026. return $this->setData(
  4027. OrderInterface::BASE_DISCOUNT_TAX_COMPENSATION_REFUNDED,
  4028. $baseDiscountTaxCompensationRefunded
  4029. );
  4030. }
  4031. /**
  4032. * @inheritdoc
  4033. */
  4034. public function setShippingInclTax($amount)
  4035. {
  4036. return $this->setData(OrderInterface::SHIPPING_INCL_TAX, $amount);
  4037. }
  4038. /**
  4039. * @inheritdoc
  4040. */
  4041. public function setBaseShippingInclTax($amount)
  4042. {
  4043. return $this->setData(OrderInterface::BASE_SHIPPING_INCL_TAX, $amount);
  4044. }
  4045. /**
  4046. * Sets shipping method to order
  4047. *
  4048. * @param string $shippingMethod
  4049. * @return $this
  4050. * @internal
  4051. */
  4052. public function setShippingMethod($shippingMethod)
  4053. {
  4054. return $this->setData('shipping_method', $shippingMethod);
  4055. }
  4056. //@codeCoverageIgnoreEnd
  4057. }