Source for file gItem.php

Documentation is available at gItem.php

  1. <?php
  2. /**
  3. * ========================================================
  4. * phpGCheckout, Open Source PHP G Checkout Library
  5. * http://www.phpgcheckout.com
  6. * ========================================================
  7. *
  8. * Copyright (c) 2006 Expert Database Solutions, LLC
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a
  11. * copy of this software and associated documentation files (the "Software"),
  12. * to deal in the Software without restriction, including without limitation the
  13. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. * copies of the Software, and to permit persons to whom the Software is
  15. * furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice shall be included in all
  18. * copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  21. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  22. * PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  24. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
  25. * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. *
  27. */
  28.  
  29.  
  30. /**
  31. * Representation of a Shopping cart item.
  32. *
  33. */
  34. class gItem {
  35. var $_name;
  36. var $_description;
  37. var $_price;
  38. var $_quantity;
  39. var $_private_item_data;
  40. var $_tax_table_selector;
  41. /**
  42. * Default Constructor
  43. *
  44. * @param unknown_type $name
  45. * @param unknown_type $description
  46. * @param unknown_type $price
  47. * @param unknown_type $quantity
  48. * @param string XML Document $private_item_data
  49. * @return gItem
  50. */
  51. function gItem($name, $description, $quantity, $price, $tax_table_selector = "", $private_item_data = "") {
  52. $this->_name = $name;
  53. $this->_description = $description;
  54. $this->_price = $price;
  55. $this->_quantity = $quantity;
  56. $this->_private_item_data = $private_item_data;
  57. $this->_tax_table_selector= $tax_table_selector;
  58. }
  59. /**
  60. * Enter the name of the alternate tax table that you want
  61. * to use to calculate tax for this item.
  62. *
  63. * @param unknown_type $tax_table_selector
  64. */
  65. function setTaxTableSelector($tax_table_selector){
  66. $this->_tax_table_selector = $tax_table_selector;
  67. }
  68. /**
  69. * Add any valid XML document to the item.
  70. *
  71. * @param unknown_type $private_item_data
  72. */
  73. function setPrivateItemData($private_item_data){
  74. $this->_private_item_data = $private_item_data;
  75. }
  76. /**
  77. * return Google Checkout XML
  78. *
  79. * @return unknown
  80. */
  81. function getXML() {
  82. $currency = $GLOBALS['GCheckout_currency'];
  83. $str_xml = " <item>";
  84. $str_xml .= " <item-name>$this->_name</item-name>";
  85. $str_xml .= " <item-description>$this->_description</item-description>";
  86. $str_xml .= " <unit-price currency=\"$currency\">$this->_price</unit-price>";
  87. $str_xml .= " <quantity>$this->_quantity</quantity>";
  88. if(!empty($this->_tax_table_selector))
  89. $str_xml .= " <tax-table-selector>$this->_tax_table_selector</tax-table-selector>";
  90. if(!empty($this->_private_item_data))
  91. $str_xml .= " <merchant-private-item-data>$this->_private_item_data</merchant-private-item-data>";
  92. $str_xml .= " </item>";
  93. return $str_xml;
  94. }
  95. }
  96. ?>

Documentation generated on Mon, 04 Dec 2006 11:09:33 -0500 by phpDocumentor 1.3.0RC3