cart.html 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Shopping Cart Class &mdash; CodeIgniter 3.1.11 documentation</title>
  8. <link rel="shortcut icon" href="../_static/ci-icon.ico"/>
  9. <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
  10. <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
  11. <link rel="index" title="Index"
  12. href="../genindex.html"/>
  13. <link rel="search" title="Search" href="../search.html"/>
  14. <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/>
  15. <link rel="up" title="Libraries" href="index.html"/>
  16. <link rel="next" title="Config Class" href="config.html"/>
  17. <link rel="prev" title="Calendaring Class" href="calendar.html"/>
  18. <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
  19. </head>
  20. <body class="wy-body-for-nav" role="document">
  21. <div id="nav">
  22. <div id="nav_inner">
  23. <div id="pulldown-menu" class="ciNav">
  24. <ul>
  25. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  26. </ul>
  27. <ul>
  28. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  29. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  30. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  31. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  32. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  33. </ul>
  34. </li>
  35. </ul>
  36. <ul>
  37. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  38. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  39. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  44. </ul>
  45. </li>
  46. </ul>
  47. <ul>
  48. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  49. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  52. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  53. </ul>
  54. </li>
  55. </ul>
  56. <ul>
  57. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  58. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  59. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  60. </ul>
  61. </li>
  62. </ul>
  63. <ul>
  64. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  65. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  66. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  67. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  68. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  69. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  70. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  71. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  72. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  73. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  74. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  75. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  76. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  77. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  78. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  79. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  80. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  81. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  82. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  83. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  84. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  85. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  86. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  87. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  88. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  89. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  90. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  91. </ul>
  92. </li>
  93. </ul>
  94. <ul class="current">
  95. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current">
  96. <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li>
  97. <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li>
  98. <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li>
  99. <li class="toctree-l2 current"><a class="current reference internal" href="#">Shopping Cart Class</a></li>
  100. <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li>
  101. <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li>
  102. <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li>
  103. <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li>
  104. <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li>
  105. <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li>
  106. <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li>
  107. <li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li>
  108. <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li>
  109. <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li>
  110. <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li>
  111. <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li>
  112. <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li>
  113. <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li>
  114. <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li>
  115. <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li>
  116. <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li>
  117. <li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li>
  118. <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li>
  119. <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li>
  120. <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li>
  121. <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li>
  122. <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li>
  123. <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li>
  124. <li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
  125. <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li>
  126. </ul>
  127. </li>
  128. </ul>
  129. <ul>
  130. <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
  131. <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
  132. <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
  133. <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
  134. <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
  135. <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
  136. <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
  137. <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
  138. <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
  139. <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
  140. <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
  141. <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
  142. <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
  143. <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
  144. <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
  145. </ul>
  146. </li>
  147. </ul>
  148. <ul>
  149. <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
  150. <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
  151. <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li>
  152. <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
  153. <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
  154. <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li>
  155. <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li>
  156. <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li>
  157. <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li>
  158. <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
  159. <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
  160. <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
  161. <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li>
  162. <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
  163. <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li>
  164. <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
  165. <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li>
  166. <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li>
  167. <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
  168. <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li>
  169. <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
  170. <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
  171. </ul>
  172. </li>
  173. </ul>
  174. </div>
  175. </div>
  176. </div>
  177. <div id="nav2">
  178. <a href="#" id="openToc">
  179. <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAKwCaAwERAAIRAQMRAf/EAHsAAQAABwEBAAAAAAAAAAAAAAABAwQFBgcIAgkBAQAAAAAAAAAAAAAAAAAAAAAQAAEDAwICBwYEAgsAAAAAAAIBAwQAEQUSBiEHkROTVNQWGDFBUVIUCHEiMtOUFWGBobHRQlMkZIRVEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwDSC+ygkOOaUoKigUCgUCgUCgUCgUCgUCgUCgkuGguIP9FBMFb0Hqg7We+3jlmIqqYFf4ub+/QYlnOR/LqIBKGFUbf8qWv971BytQXXE7Y3Lnm3HsFhp2TaZJAdchRXpIgSpdEJWxJEW3xoKV7F5OMy7JkQn2o7D6w33XGjEAkoiqrJEqIiOIiKuhePCgqp22dyYyS3CyWHnQ5joG61HkRnmnTbaFSMhExRVQRRVJU9iUHjE7ez+fJ0MFipmUNhBV8YUd2SoIV9KkjQla9ltegttBdPLW4/qocL+UTfrMiHW4+P9M71shuyrqaHTcxsl7jegpsji8nh5ZwMvDfgTm0RTjSmjYdFCS6KoOIipdFunCgmNYTMv457MMY6U7iI6oMieDDhRm1VbIhuoOkbqtuK0Hpzb+eZcYZexUxt6UyUqK2cd0SdjtgrhOgijcgERUlJOCIl6CpgbP3blRI8XgMjNARAyKNDfeRBdFDBVUAXgQrqH4pxoJTu2NysY97LP4ac1io5q1InHFeGO24LnVKJuKOkSQ/yKir+rh7aCLG1dzypZQI2FnvTgccYOM3FeN0XWERXAUEFVQgQkUktdLpegm+Td3/Xli/L+S/mYNJIOF9G/wBeLKrZHFb0akG6W1WtQWSg3Dyg5e7V3fipE3O4/wCrktyzYA+ufas2LbZIlmnAT2kvuoN1wft95augilglX/tzP3qCu9O3LL/wV/i5v79BvmTADq14UGu91467Z6U9y0HzH/ncj/U/sT/CgynZG7I2NezpZGUjIycJkYkZSG+uQ81pbBNKLxJfjwoMqZ3/ALYHl35AJ7/cuwHcu5k7r1Q5pHetBjquqVVJWGxj9Zrtcl/Ggy3dHMvauR3HFZj5nHNxSyW5JISYDMoIwx8tFIGHZhPNaykGapr6rUAiicEoMG21lMRj8buPAz8xhJrr7uOeiPTCyAwXUaGR1mgozbTusOsFLEiJ7fbQa/h7gcjy2H3V6xppwDNtUSxCJIqp7valBuWVzJ22xuCROXNNZiJkMtms0DbjUkAZjzoDrTMd9dDRI44ZC2YsrYdKWP2WDT2S3N9dNdlRYrGMYc06IURXSYb0igrpWS485xVNS6nF4rwslkoMwnbpgZLB7bmt5uMweAhDEl4B5uSLzzqTnnyVpW2jaJHRMSIjdDiiotvy3DOE5rYTEbkl5yFn28k7JyG4c7AU2HtLH1uKfaiMPI40CdYbpNtmLdwTSn5rewLNld+7TLdeal4WarWBkbVKBjgdElMJJwAAY5fl4kB3b1fp4XvagsGS3FjJfLzDNtS8aeXx7LzT7TyzByQE5PccRGRC0ZRUDRV6y62vbjagzLmJzS2vuPK43JY6aP1TW6Jz+RIWyFtyC06y3EkiiinAo7YCqfq1AqqnGgsOH3lhZO8d1pmcpB8j5XIm9OYlBJSQ/FSS4427DKO0RC8AlcEMhFdViRR1WDWR5t3WXVuL1d106kG9vdeye2g60+1FDyW0shIcXVpyroXt8I8dfd+NB1vioAdWnD3UF1+gD4UFc6CEKpagxXN43rwJLUHz7yX2c8zokt9uHlsPIhA4aRnnHJTLptIS6CNsY7iASpxUUMkReGpfbQW0vtN5pitvrsN28rwtBD0nc0+/Yft5XhaB6TuaXfsP28rwtA9J3NPv2H7eV4Wgek7mn37D9vK8LQPSdzT79h+3leFoHpO5pd+w/byvC0D0nc0u/Yft5XhaB6TuaXfsP28rwtA9J3NLv2H7eV4Wgek7ml37D9vK8LQPSdzS79h+3leFoHpO5p9+w/byvC0E9r7Reazy2HIYVPxkS/CUHVn26cosxyv2g7h89LYmZSXOenvLEQ1YaQ222RATcQCP8rSGqqA8S02W2pQ6FhMoAIlqCtsnwoCpdKClejI4i3Sgtb+GBxVuNBSFt1pV/RQefLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8utJ/koJ7WCbBU/LQXOPAFq1koK8B0pag90CggtBBf6qB0UDooHRQOigdFA6KB0UDooHRQOigdFA6KB0UDooI0EaBQf//Z" title="Toggle Table of Contents" alt="Toggle Table of Contents" />
  180. </a>
  181. </div>
  182. <div class="wy-grid-for-nav">
  183. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  184. <div class="wy-side-nav-search">
  185. <a href="../index.html" class="fa fa-home"> CodeIgniter</a>
  186. <div role="search">
  187. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  188. <input type="text" name="q" placeholder="Search docs" />
  189. <input type="hidden" name="check_keywords" value="yes" />
  190. <input type="hidden" name="area" value="default" />
  191. </form>
  192. </div>
  193. </div>
  194. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  195. <ul>
  196. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  197. </ul>
  198. <ul>
  199. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  200. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  201. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  202. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  203. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  204. </ul>
  205. </li>
  206. </ul>
  207. <ul>
  208. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  209. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  210. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  211. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  212. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  213. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  214. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  215. </ul>
  216. </li>
  217. </ul>
  218. <ul>
  219. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  220. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  221. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  222. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  223. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  224. </ul>
  225. </li>
  226. </ul>
  227. <ul>
  228. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  229. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  230. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  231. </ul>
  232. </li>
  233. </ul>
  234. <ul>
  235. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  236. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  237. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  238. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  239. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  240. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  241. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  242. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  243. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  244. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  245. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  246. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  247. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  248. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  249. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  250. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  251. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  252. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  253. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  254. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  255. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  256. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  257. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  258. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  259. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  260. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  261. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  262. </ul>
  263. </li>
  264. </ul>
  265. <ul class="current">
  266. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current">
  267. <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li>
  268. <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li>
  269. <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li>
  270. <li class="toctree-l2 current"><a class="current reference internal" href="#">Shopping Cart Class</a></li>
  271. <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li>
  272. <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li>
  273. <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li>
  274. <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li>
  275. <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li>
  276. <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li>
  277. <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li>
  278. <li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li>
  279. <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li>
  280. <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li>
  281. <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li>
  282. <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li>
  283. <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li>
  284. <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li>
  285. <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li>
  286. <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li>
  287. <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li>
  288. <li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li>
  289. <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li>
  290. <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li>
  291. <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li>
  292. <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li>
  293. <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li>
  294. <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li>
  295. <li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
  296. <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li>
  297. </ul>
  298. </li>
  299. </ul>
  300. <ul>
  301. <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
  302. <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
  303. <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
  304. <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
  305. <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
  306. <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
  307. <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
  308. <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
  309. <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
  310. <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
  311. <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
  312. <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
  313. <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
  314. <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
  315. <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
  316. </ul>
  317. </li>
  318. </ul>
  319. <ul>
  320. <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
  321. <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
  322. <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li>
  323. <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
  324. <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
  325. <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li>
  326. <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li>
  327. <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li>
  328. <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li>
  329. <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
  330. <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
  331. <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
  332. <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li>
  333. <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
  334. <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li>
  335. <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
  336. <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li>
  337. <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li>
  338. <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
  339. <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li>
  340. <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
  341. <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
  342. </ul>
  343. </li>
  344. </ul>
  345. </div>
  346. &nbsp;
  347. </nav>
  348. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  349. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  350. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  351. <a href="../index.html">CodeIgniter</a>
  352. </nav>
  353. <div class="wy-nav-content">
  354. <div class="rst-content">
  355. <div role="navigation" aria-label="breadcrumbs navigation">
  356. <ul class="wy-breadcrumbs">
  357. <li><a href="../index.html">Docs</a> &raquo;</li>
  358. <li><a href="index.html">Libraries</a> &raquo;</li>
  359. <li>Shopping Cart Class</li>
  360. <li class="wy-breadcrumbs-aside">
  361. </li>
  362. <div style="float:right;margin-left:5px;" id="closeMe">
  363. <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" />
  364. </div>
  365. </ul>
  366. <hr/>
  367. </div>
  368. <div role="main" class="document">
  369. <div class="section" id="shopping-cart-class">
  370. <h1>Shopping Cart Class<a class="headerlink" href="#shopping-cart-class" title="Permalink to this headline">¶</a></h1>
  371. <p>The Cart Class permits items to be added to a session that stays active
  372. while a user is browsing your site. These items can be retrieved and
  373. displayed in a standard “shopping cart” format, allowing the user to
  374. update the quantity or remove items from the cart.</p>
  375. <div class="admonition important">
  376. <p class="first admonition-title">Important</p>
  377. <p class="last">The Cart library is DEPRECATED and should not be used.
  378. It is currently only kept for backwards compatibility.</p>
  379. </div>
  380. <p>Please note that the Cart Class ONLY provides the core “cart”
  381. functionality. It does not provide shipping, credit card authorization,
  382. or other processing components.</p>
  383. <div class="contents local topic" id="contents">
  384. <ul class="simple">
  385. <li><a class="reference internal" href="#using-the-cart-class" id="id1">Using the Cart Class</a><ul>
  386. <li><a class="reference internal" href="#initializing-the-shopping-cart-class" id="id2">Initializing the Shopping Cart Class</a></li>
  387. <li><a class="reference internal" href="#adding-an-item-to-the-cart" id="id3">Adding an Item to The Cart</a></li>
  388. <li><a class="reference internal" href="#adding-multiple-items-to-the-cart" id="id4">Adding Multiple Items to The Cart</a></li>
  389. <li><a class="reference internal" href="#displaying-the-cart" id="id5">Displaying the Cart</a></li>
  390. <li><a class="reference internal" href="#updating-the-cart" id="id6">Updating The Cart</a><ul>
  391. <li><a class="reference internal" href="#what-is-a-row-id" id="id7">What is a Row ID?</a></li>
  392. </ul>
  393. </li>
  394. </ul>
  395. </li>
  396. <li><a class="reference internal" href="#class-reference" id="id8">Class Reference</a></li>
  397. </ul>
  398. </div>
  399. <div class="custom-index container"></div><div class="section" id="using-the-cart-class">
  400. <h2><a class="toc-backref" href="#id1">Using the Cart Class</a><a class="headerlink" href="#using-the-cart-class" title="Permalink to this headline">¶</a></h2>
  401. <div class="section" id="initializing-the-shopping-cart-class">
  402. <h3><a class="toc-backref" href="#id2">Initializing the Shopping Cart Class</a><a class="headerlink" href="#initializing-the-shopping-cart-class" title="Permalink to this headline">¶</a></h3>
  403. <div class="admonition important">
  404. <p class="first admonition-title">Important</p>
  405. <p class="last">The Cart class utilizes CodeIgniter’s <a class="reference internal" href="sessions.html"><span class="doc">Session
  406. Class</span></a> to save the cart information to a database, so
  407. before using the Cart class you must set up a database table as
  408. indicated in the <a class="reference internal" href="sessions.html"><span class="doc">Session Documentation</span></a>, and set the
  409. session preferences in your application/config/config.php file to
  410. utilize a database.</p>
  411. </div>
  412. <p>To initialize the Shopping Cart Class in your controller constructor,
  413. use the <code class="docutils literal"><span class="pre">$this-&gt;load-&gt;library()</span></code> method:</p>
  414. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">library</span><span class="p">(</span><span class="s1">&#39;cart&#39;</span><span class="p">);</span>
  415. </pre></div>
  416. </div>
  417. <p>Once loaded, the Cart object will be available using:</p>
  418. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span>
  419. </pre></div>
  420. </div>
  421. <div class="admonition note">
  422. <p class="first admonition-title">Note</p>
  423. <p class="last">The Cart Class will load and initialize the Session Class
  424. automatically, so unless you are using sessions elsewhere in your
  425. application, you do not need to load the Session class.</p>
  426. </div>
  427. </div>
  428. <div class="section" id="adding-an-item-to-the-cart">
  429. <h3><a class="toc-backref" href="#id3">Adding an Item to The Cart</a><a class="headerlink" href="#adding-an-item-to-the-cart" title="Permalink to this headline">¶</a></h3>
  430. <p>To add an item to the shopping cart, simply pass an array with the
  431. product information to the <code class="docutils literal"><span class="pre">$this-&gt;cart-&gt;insert()</span></code> method, as shown
  432. below:</p>
  433. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  434. <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;sku_123ABC&#39;</span><span class="p">,</span>
  435. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">,</span>
  436. <span class="s1">&#39;price&#39;</span> <span class="o">=&gt;</span> <span class="mf">39.95</span><span class="p">,</span>
  437. <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;T-Shirt&#39;</span><span class="p">,</span>
  438. <span class="s1">&#39;options&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;Size&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;L&#39;</span><span class="p">,</span> <span class="s1">&#39;Color&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Red&#39;</span><span class="p">)</span>
  439. <span class="p">);</span>
  440. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">insert</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
  441. </pre></div>
  442. </div>
  443. <div class="admonition important">
  444. <p class="first admonition-title">Important</p>
  445. <p class="last">The first four array indexes above (id, qty, price, and
  446. name) are <strong>required</strong>. If you omit any of them the data will not be
  447. saved to the cart. The fifth index (options) is optional. It is intended
  448. to be used in cases where your product has options associated with it.
  449. Use an array for options, as shown above.</p>
  450. </div>
  451. <p>The five reserved indexes are:</p>
  452. <ul class="simple">
  453. <li><strong>id</strong> - Each product in your store must have a unique identifier.
  454. Typically this will be an “sku” or other such identifier.</li>
  455. <li><strong>qty</strong> - The quantity being purchased.</li>
  456. <li><strong>price</strong> - The price of the item.</li>
  457. <li><strong>name</strong> - The name of the item.</li>
  458. <li><strong>options</strong> - Any additional attributes that are needed to identify
  459. the product. These must be passed via an array.</li>
  460. </ul>
  461. <p>In addition to the five indexes above, there are two reserved words:
  462. rowid and subtotal. These are used internally by the Cart class, so
  463. please do NOT use those words as index names when inserting data into
  464. the cart.</p>
  465. <p>Your array may contain additional data. Anything you include in your
  466. array will be stored in the session. However, it is best to standardize
  467. your data among all your products in order to make displaying the
  468. information in a table easier.</p>
  469. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  470. <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;sku_123ABC&#39;</span><span class="p">,</span>
  471. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">,</span>
  472. <span class="s1">&#39;price&#39;</span> <span class="o">=&gt;</span> <span class="mf">39.95</span><span class="p">,</span>
  473. <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;T-Shirt&#39;</span><span class="p">,</span>
  474. <span class="s1">&#39;coupon&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;XMAS-50OFF&#39;</span>
  475. <span class="p">);</span>
  476. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">insert</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
  477. </pre></div>
  478. </div>
  479. <p>The <code class="docutils literal"><span class="pre">insert()</span></code> method will return the $rowid if you successfully insert a
  480. single item.</p>
  481. </div>
  482. <div class="section" id="adding-multiple-items-to-the-cart">
  483. <h3><a class="toc-backref" href="#id4">Adding Multiple Items to The Cart</a><a class="headerlink" href="#adding-multiple-items-to-the-cart" title="Permalink to this headline">¶</a></h3>
  484. <p>By using a multi-dimensional array, as shown below, it is possible to
  485. add multiple products to the cart in one action. This is useful in cases
  486. where you wish to allow people to select from among several items on the
  487. same page.</p>
  488. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  489. <span class="k">array</span><span class="p">(</span>
  490. <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;sku_123ABC&#39;</span><span class="p">,</span>
  491. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">,</span>
  492. <span class="s1">&#39;price&#39;</span> <span class="o">=&gt;</span> <span class="mf">39.95</span><span class="p">,</span>
  493. <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;T-Shirt&#39;</span><span class="p">,</span>
  494. <span class="s1">&#39;options&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;Size&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;L&#39;</span><span class="p">,</span> <span class="s1">&#39;Color&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Red&#39;</span><span class="p">)</span>
  495. <span class="p">),</span>
  496. <span class="k">array</span><span class="p">(</span>
  497. <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;sku_567ZYX&#39;</span><span class="p">,</span>
  498. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">,</span>
  499. <span class="s1">&#39;price&#39;</span> <span class="o">=&gt;</span> <span class="mf">9.95</span><span class="p">,</span>
  500. <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Coffee Mug&#39;</span>
  501. <span class="p">),</span>
  502. <span class="k">array</span><span class="p">(</span>
  503. <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;sku_965QRS&#39;</span><span class="p">,</span>
  504. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">,</span>
  505. <span class="s1">&#39;price&#39;</span> <span class="o">=&gt;</span> <span class="mf">29.95</span><span class="p">,</span>
  506. <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Shot Glass&#39;</span>
  507. <span class="p">)</span>
  508. <span class="p">);</span>
  509. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">insert</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
  510. </pre></div>
  511. </div>
  512. </div>
  513. <div class="section" id="displaying-the-cart">
  514. <h3><a class="toc-backref" href="#id5">Displaying the Cart</a><a class="headerlink" href="#displaying-the-cart" title="Permalink to this headline">¶</a></h3>
  515. <p>To display the cart you will create a <a class="reference internal" href="../general/views.html"><span class="doc">view
  516. file</span></a> with code similar to the one shown below.</p>
  517. <p>Please note that this example uses the <a class="reference internal" href="../helpers/form_helper.html"><span class="doc">form
  518. helper</span></a>.</p>
  519. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">&#39;path/to/controller/update/method&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span>
  520. <span class="p">&lt;</span><span class="nt">table</span> <span class="na">cellpadding</span><span class="o">=</span><span class="s">&quot;6&quot;</span> <span class="na">cellspacing</span><span class="o">=</span><span class="s">&quot;1&quot;</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;width:100%&quot;</span> <span class="na">border</span><span class="o">=</span><span class="s">&quot;0&quot;</span><span class="p">&gt;</span>
  521. <span class="p">&lt;</span><span class="nt">tr</span><span class="p">&gt;</span>
  522. <span class="p">&lt;</span><span class="nt">th</span><span class="p">&gt;</span>QTY<span class="p">&lt;/</span><span class="nt">th</span><span class="p">&gt;</span>
  523. <span class="p">&lt;</span><span class="nt">th</span><span class="p">&gt;</span>Item Description<span class="p">&lt;/</span><span class="nt">th</span><span class="p">&gt;</span>
  524. <span class="p">&lt;</span><span class="nt">th</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;text-align:right&quot;</span><span class="p">&gt;</span>Item Price<span class="p">&lt;/</span><span class="nt">th</span><span class="p">&gt;</span>
  525. <span class="p">&lt;</span><span class="nt">th</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;text-align:right&quot;</span><span class="p">&gt;</span>Sub-Total<span class="p">&lt;/</span><span class="nt">th</span><span class="p">&gt;</span>
  526. <span class="p">&lt;/</span><span class="nt">tr</span><span class="p">&gt;</span>
  527. <span class="cp">&lt;?php</span> <span class="nv">$i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="cp">?&gt;</span>
  528. <span class="cp">&lt;?php</span> <span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">contents</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$items</span><span class="p">)</span><span class="o">:</span> <span class="cp">?&gt;</span>
  529. <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">form_hidden</span><span class="p">(</span><span class="nv">$i</span><span class="o">.</span><span class="s1">&#39;[rowid]&#39;</span><span class="p">,</span> <span class="nv">$items</span><span class="p">[</span><span class="s1">&#39;rowid&#39;</span><span class="p">]);</span> <span class="cp">?&gt;</span>
  530. <span class="p">&lt;</span><span class="nt">tr</span><span class="p">&gt;</span>
  531. <span class="p">&lt;</span><span class="nt">td</span><span class="p">&gt;</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">form_input</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="nv">$i</span><span class="o">.</span><span class="s1">&#39;[qty]&#39;</span><span class="p">,</span> <span class="s1">&#39;value&#39;</span> <span class="o">=&gt;</span> <span class="nv">$items</span><span class="p">[</span><span class="s1">&#39;qty&#39;</span><span class="p">],</span> <span class="s1">&#39;maxlength&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;3&#39;</span><span class="p">,</span> <span class="s1">&#39;size&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;5&#39;</span><span class="p">));</span> <span class="cp">?&gt;</span><span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>
  532. <span class="p">&lt;</span><span class="nt">td</span><span class="p">&gt;</span>
  533. <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$items</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">];</span> <span class="cp">?&gt;</span>
  534. <span class="cp">&lt;?php</span> <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">has_options</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">&#39;rowid&#39;</span><span class="p">])</span> <span class="o">==</span> <span class="k">TRUE</span><span class="p">)</span><span class="o">:</span> <span class="cp">?&gt;</span>
  535. <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>
  536. <span class="cp">&lt;?php</span> <span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">product_options</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">&#39;rowid&#39;</span><span class="p">])</span> <span class="k">as</span> <span class="nv">$option_name</span> <span class="o">=&gt;</span> <span class="nv">$option_value</span><span class="p">)</span><span class="o">:</span> <span class="cp">?&gt;</span>
  537. <span class="p">&lt;</span><span class="nt">strong</span><span class="p">&gt;</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$option_name</span><span class="p">;</span> <span class="cp">?&gt;</span>:<span class="p">&lt;/</span><span class="nt">strong</span><span class="p">&gt;</span> <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$option_value</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="p">&lt;</span><span class="nt">br</span> <span class="p">/&gt;</span>
  538. <span class="cp">&lt;?php</span> <span class="k">endforeach</span><span class="p">;</span> <span class="cp">?&gt;</span>
  539. <span class="p">&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  540. <span class="cp">&lt;?php</span> <span class="k">endif</span><span class="p">;</span> <span class="cp">?&gt;</span>
  541. <span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>
  542. <span class="p">&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;text-align:right&quot;</span><span class="p">&gt;</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">format_number</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">&#39;price&#39;</span><span class="p">]);</span> <span class="cp">?&gt;</span><span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>
  543. <span class="p">&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;text-align:right&quot;</span><span class="p">&gt;</span>$<span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">format_number</span><span class="p">(</span><span class="nv">$items</span><span class="p">[</span><span class="s1">&#39;subtotal&#39;</span><span class="p">]);</span> <span class="cp">?&gt;</span><span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>
  544. <span class="p">&lt;/</span><span class="nt">tr</span><span class="p">&gt;</span>
  545. <span class="cp">&lt;?php</span> <span class="nv">$i</span><span class="o">++</span><span class="p">;</span> <span class="cp">?&gt;</span>
  546. <span class="cp">&lt;?php</span> <span class="k">endforeach</span><span class="p">;</span> <span class="cp">?&gt;</span>
  547. <span class="p">&lt;</span><span class="nt">tr</span><span class="p">&gt;</span>
  548. <span class="p">&lt;</span><span class="nt">td</span> <span class="na">colspan</span><span class="o">=</span><span class="s">&quot;2&quot;</span><span class="p">&gt;</span> <span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>
  549. <span class="p">&lt;</span><span class="nt">td</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;right&quot;</span><span class="p">&gt;&lt;</span><span class="nt">strong</span><span class="p">&gt;</span>Total<span class="p">&lt;/</span><span class="nt">strong</span><span class="p">&gt;&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>
  550. <span class="p">&lt;</span><span class="nt">td</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;right&quot;</span><span class="p">&gt;</span>$<span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">format_number</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">total</span><span class="p">());</span> <span class="cp">?&gt;</span><span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>
  551. <span class="p">&lt;/</span><span class="nt">tr</span><span class="p">&gt;</span>
  552. <span class="p">&lt;/</span><span class="nt">table</span><span class="p">&gt;</span>
  553. <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">form_submit</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;Update your Cart&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="p">&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  554. </pre></div>
  555. </div>
  556. </div>
  557. <div class="section" id="updating-the-cart">
  558. <h3><a class="toc-backref" href="#id6">Updating The Cart</a><a class="headerlink" href="#updating-the-cart" title="Permalink to this headline">¶</a></h3>
  559. <p>To update the information in your cart, you must pass an array
  560. containing the Row ID and one or more pre-defined properties to the
  561. <code class="docutils literal"><span class="pre">$this-&gt;cart-&gt;update()</span></code> method.</p>
  562. <div class="admonition note">
  563. <p class="first admonition-title">Note</p>
  564. <p class="last">If the quantity is set to zero, the item will be removed from
  565. the cart.</p>
  566. </div>
  567. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  568. <span class="s1">&#39;rowid&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;b99ccdf16028f015540f341130b6d8ec&#39;</span><span class="p">,</span>
  569. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">3</span>
  570. <span class="p">);</span>
  571. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">update</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
  572. <span class="c1">// Or a multi-dimensional array</span>
  573. <span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  574. <span class="k">array</span><span class="p">(</span>
  575. <span class="s1">&#39;rowid&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;b99ccdf16028f015540f341130b6d8ec&#39;</span><span class="p">,</span>
  576. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">3</span>
  577. <span class="p">),</span>
  578. <span class="k">array</span><span class="p">(</span>
  579. <span class="s1">&#39;rowid&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;xw82g9q3r495893iajdh473990rikw23&#39;</span><span class="p">,</span>
  580. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">4</span>
  581. <span class="p">),</span>
  582. <span class="k">array</span><span class="p">(</span>
  583. <span class="s1">&#39;rowid&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;fh4kdkkkaoe30njgoe92rkdkkobec333&#39;</span><span class="p">,</span>
  584. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">2</span>
  585. <span class="p">)</span>
  586. <span class="p">);</span>
  587. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">update</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
  588. </pre></div>
  589. </div>
  590. <p>You may also update any property you have previously defined when
  591. inserting the item such as options, price or other custom fields.</p>
  592. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
  593. <span class="s1">&#39;rowid&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;b99ccdf16028f015540f341130b6d8ec&#39;</span><span class="p">,</span>
  594. <span class="s1">&#39;qty&#39;</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">,</span>
  595. <span class="s1">&#39;price&#39;</span> <span class="o">=&gt;</span> <span class="mf">49.95</span><span class="p">,</span>
  596. <span class="s1">&#39;coupon&#39;</span> <span class="o">=&gt;</span> <span class="k">NULL</span>
  597. <span class="p">);</span>
  598. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cart</span><span class="o">-&gt;</span><span class="na">update</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
  599. </pre></div>
  600. </div>
  601. <div class="section" id="what-is-a-row-id">
  602. <h4><a class="toc-backref" href="#id7">What is a Row ID?</a><a class="headerlink" href="#what-is-a-row-id" title="Permalink to this headline">¶</a></h4>
  603. <p>The row ID is a unique identifier that is generated by the cart code
  604. when an item is added to the cart. The reason a unique ID is created
  605. is so that identical products with different options can be managed
  606. by the cart.</p>
  607. <p>For example, let’s say someone buys two identical t-shirts (same product
  608. ID), but in different sizes. The product ID (and other attributes) will
  609. be identical for both sizes because it’s the same shirt. The only
  610. difference will be the size. The cart must therefore have a means of
  611. identifying this difference so that the two sizes of shirts can be
  612. managed independently. It does so by creating a unique “row ID” based on
  613. the product ID and any options associated with it.</p>
  614. <p>In nearly all cases, updating the cart will be something the user does
  615. via the “view cart” page, so as a developer, it is unlikely that you
  616. will ever have to concern yourself with the “row ID”, other than making
  617. sure your “view cart” page contains this information in a hidden form
  618. field, and making sure it gets passed to the <code class="docutils literal"><span class="pre">update()</span></code> method when
  619. the update form is submitted. Please examine the construction of the
  620. “view cart” page above for more information.</p>
  621. </div>
  622. </div>
  623. </div>
  624. <div class="section" id="class-reference">
  625. <h2><a class="toc-backref" href="#id8">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2>
  626. <dl class="class">
  627. <dt id="CI_Cart">
  628. <em class="property">class </em><code class="descname">CI_Cart</code><a class="headerlink" href="#CI_Cart" title="Permalink to this definition">¶</a></dt>
  629. <dd><dl class="attribute">
  630. <dt>
  631. <code class="descname">$product_id_rules = '.a-z0-9_-'</code></dt>
  632. <dd><p>These are the regular expression rules that we use to validate the product
  633. ID - alpha-numeric, dashes, underscores, or periods by default</p>
  634. </dd></dl>
  635. <dl class="attribute">
  636. <dt>
  637. <code class="descname">$product_name_rules = 'w -.:'</code></dt>
  638. <dd><p>These are the regular expression rules that we use to validate the product ID and product name - alpha-numeric, dashes, underscores, colons or periods by
  639. default</p>
  640. </dd></dl>
  641. <dl class="attribute">
  642. <dt>
  643. <code class="descname">$product_name_safe = TRUE</code></dt>
  644. <dd><p>Whether or not to only allow safe product names. Default TRUE.</p>
  645. </dd></dl>
  646. <dl class="method">
  647. <dt id="CI_Cart::insert">
  648. <code class="descname">insert</code><span class="sig-paren">(</span><span class="optional">[</span><em>$items = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::insert" title="Permalink to this definition">¶</a></dt>
  649. <dd><table class="docutils field-list" frame="void" rules="none">
  650. <col class="field-name" />
  651. <col class="field-body" />
  652. <tbody valign="top">
  653. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  654. <li><strong>$items</strong> (<em>array</em>) – Items to insert into the cart</li>
  655. </ul>
  656. </td>
  657. </tr>
  658. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p>
  659. </td>
  660. </tr>
  661. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  662. </td>
  663. </tr>
  664. </tbody>
  665. </table>
  666. <p>Insert items into the cart and save it to the session table. Returns TRUE
  667. on success and FALSE on failure.</p>
  668. </dd></dl>
  669. <dl class="method">
  670. <dt id="CI_Cart::update">
  671. <code class="descname">update</code><span class="sig-paren">(</span><span class="optional">[</span><em>$items = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::update" title="Permalink to this definition">¶</a></dt>
  672. <dd><table class="docutils field-list" frame="void" rules="none">
  673. <col class="field-name" />
  674. <col class="field-body" />
  675. <tbody valign="top">
  676. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  677. <li><strong>$items</strong> (<em>array</em>) – Items to update in the cart</li>
  678. </ul>
  679. </td>
  680. </tr>
  681. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p>
  682. </td>
  683. </tr>
  684. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  685. </td>
  686. </tr>
  687. </tbody>
  688. </table>
  689. <p>This method permits changing the properties of a given item.
  690. Typically it is called from the “view cart” page if a user makes changes
  691. to the quantity before checkout. That array must contain the rowid
  692. for each item.</p>
  693. </dd></dl>
  694. <dl class="method">
  695. <dt id="CI_Cart::remove">
  696. <code class="descname">remove</code><span class="sig-paren">(</span><em>$rowid</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::remove" title="Permalink to this definition">¶</a></dt>
  697. <dd><table class="docutils field-list" frame="void" rules="none">
  698. <col class="field-name" />
  699. <col class="field-body" />
  700. <tbody valign="top">
  701. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  702. <li><strong>$rowid</strong> (<em>int</em>) – ID of the item to remove from the cart</li>
  703. </ul>
  704. </td>
  705. </tr>
  706. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p>
  707. </td>
  708. </tr>
  709. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  710. </td>
  711. </tr>
  712. </tbody>
  713. </table>
  714. <p>Allows you to remove an item from the shopping cart by passing it the
  715. <code class="docutils literal"><span class="pre">$rowid</span></code>.</p>
  716. </dd></dl>
  717. <dl class="method">
  718. <dt id="CI_Cart::total">
  719. <code class="descname">total</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::total" title="Permalink to this definition">¶</a></dt>
  720. <dd><table class="docutils field-list" frame="void" rules="none">
  721. <col class="field-name" />
  722. <col class="field-body" />
  723. <tbody valign="top">
  724. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Total amount</td>
  725. </tr>
  726. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td>
  727. </tr>
  728. </tbody>
  729. </table>
  730. <p>Displays the total amount in the cart.</p>
  731. </dd></dl>
  732. <dl class="method">
  733. <dt id="CI_Cart::total_items">
  734. <code class="descname">total_items</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::total_items" title="Permalink to this definition">¶</a></dt>
  735. <dd><table class="docutils field-list" frame="void" rules="none">
  736. <col class="field-name" />
  737. <col class="field-body" />
  738. <tbody valign="top">
  739. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Total amount of items in the cart</td>
  740. </tr>
  741. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td>
  742. </tr>
  743. </tbody>
  744. </table>
  745. <p>Displays the total number of items in the cart.</p>
  746. </dd></dl>
  747. <dl class="method">
  748. <dt id="CI_Cart::contents">
  749. <code class="descname">contents</code><span class="sig-paren">(</span><span class="optional">[</span><em>$newest_first = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::contents" title="Permalink to this definition">¶</a></dt>
  750. <dd><table class="docutils field-list" frame="void" rules="none">
  751. <col class="field-name" />
  752. <col class="field-body" />
  753. <tbody valign="top">
  754. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  755. <li><strong>$newest_first</strong> (<em>bool</em>) – Whether to order the array with newest items first</li>
  756. </ul>
  757. </td>
  758. </tr>
  759. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An array of cart contents</p>
  760. </td>
  761. </tr>
  762. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p>
  763. </td>
  764. </tr>
  765. </tbody>
  766. </table>
  767. <p>Returns an array containing everything in the cart. You can sort the
  768. order by which the array is returned by passing it TRUE where the contents
  769. will be sorted from newest to oldest, otherwise it is sorted from oldest
  770. to newest.</p>
  771. </dd></dl>
  772. <dl class="method">
  773. <dt id="CI_Cart::get_item">
  774. <code class="descname">get_item</code><span class="sig-paren">(</span><em>$row_id</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::get_item" title="Permalink to this definition">¶</a></dt>
  775. <dd><table class="docutils field-list" frame="void" rules="none">
  776. <col class="field-name" />
  777. <col class="field-body" />
  778. <tbody valign="top">
  779. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  780. <li><strong>$row_id</strong> (<em>int</em>) – Row ID to retrieve</li>
  781. </ul>
  782. </td>
  783. </tr>
  784. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of item data</p>
  785. </td>
  786. </tr>
  787. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p>
  788. </td>
  789. </tr>
  790. </tbody>
  791. </table>
  792. <p>Returns an array containing data for the item matching the specified row
  793. ID, or FALSE if no such item exists.</p>
  794. </dd></dl>
  795. <dl class="method">
  796. <dt id="CI_Cart::has_options">
  797. <code class="descname">has_options</code><span class="sig-paren">(</span><em>$row_id = ''</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::has_options" title="Permalink to this definition">¶</a></dt>
  798. <dd><table class="docutils field-list" frame="void" rules="none">
  799. <col class="field-name" />
  800. <col class="field-body" />
  801. <tbody valign="top">
  802. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  803. <li><strong>$row_id</strong> (<em>int</em>) – Row ID to inspect</li>
  804. </ul>
  805. </td>
  806. </tr>
  807. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if options exist, FALSE otherwise</p>
  808. </td>
  809. </tr>
  810. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  811. </td>
  812. </tr>
  813. </tbody>
  814. </table>
  815. <p>Returns TRUE (boolean) if a particular row in the cart contains options.
  816. This method is designed to be used in a loop with <code class="docutils literal"><span class="pre">contents()</span></code>, since
  817. you must pass the rowid to this method, as shown in the Displaying
  818. the Cart example above.</p>
  819. </dd></dl>
  820. <dl class="method">
  821. <dt id="CI_Cart::product_options">
  822. <code class="descname">product_options</code><span class="sig-paren">(</span><span class="optional">[</span><em>$row_id = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::product_options" title="Permalink to this definition">¶</a></dt>
  823. <dd><table class="docutils field-list" frame="void" rules="none">
  824. <col class="field-name" />
  825. <col class="field-body" />
  826. <tbody valign="top">
  827. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  828. <li><strong>$row_id</strong> (<em>int</em>) – Row ID</li>
  829. </ul>
  830. </td>
  831. </tr>
  832. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array of product options</p>
  833. </td>
  834. </tr>
  835. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p>
  836. </td>
  837. </tr>
  838. </tbody>
  839. </table>
  840. <p>Returns an array of options for a particular product. This method is
  841. designed to be used in a loop with <code class="docutils literal"><span class="pre">contents()</span></code>, since you
  842. must pass the rowid to this method, as shown in the Displaying the
  843. Cart example above.</p>
  844. </dd></dl>
  845. <dl class="method">
  846. <dt id="CI_Cart::destroy">
  847. <code class="descname">destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Cart::destroy" title="Permalink to this definition">¶</a></dt>
  848. <dd><table class="docutils field-list" frame="void" rules="none">
  849. <col class="field-name" />
  850. <col class="field-body" />
  851. <tbody valign="top">
  852. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td>
  853. </tr>
  854. </tbody>
  855. </table>
  856. <p>Permits you to destroy the cart. This method will likely be called
  857. when you are finished processing the customer’s order.</p>
  858. </dd></dl>
  859. </dd></dl>
  860. </div>
  861. </div>
  862. </div>
  863. <footer>
  864. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  865. <a href="config.html" class="btn btn-neutral float-right" title="Config Class">Next <span class="fa fa-arrow-circle-right"></span></a>
  866. <a href="calendar.html" class="btn btn-neutral" title="Calendaring Class"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  867. </div>
  868. <hr/>
  869. <div role="contentinfo">
  870. <p>
  871. &copy; Copyright 2014 - 2019, British Columbia Institute of Technology.
  872. Last updated on Sep 19, 2019.
  873. </p>
  874. </div>
  875. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  876. </footer>
  877. </div>
  878. </div>
  879. </section>
  880. </div>
  881. <script type="text/javascript">
  882. var DOCUMENTATION_OPTIONS = {
  883. URL_ROOT:'../',
  884. VERSION:'3.1.11',
  885. COLLAPSE_INDEX:false,
  886. FILE_SUFFIX:'.html',
  887. HAS_SOURCE: false
  888. };
  889. </script>
  890. <script type="text/javascript" src="../_static/jquery.js"></script>
  891. <script type="text/javascript" src="../_static/underscore.js"></script>
  892. <script type="text/javascript" src="../_static/doctools.js"></script>
  893. <script type="text/javascript" src="../_static/js/theme.js"></script>
  894. <script type="text/javascript">
  895. jQuery(function () {
  896. SphinxRtdTheme.StickyNav.enable();
  897. });
  898. </script>
  899. </body>
  900. </html>