BxBasePaymentsServices.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * System services related to Payments.
  11. */
  12. class BxBasePaymentsServices extends BxDol
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceGetPayments()
  19. {
  20. return BxDolPayments::getInstance()->getPayments();
  21. }
  22. /**
  23. * @page service Service Calls
  24. * @section bx_system_general System Services
  25. * @subsection bx_system_general-payments Payments
  26. * @subsubsection bx_system_general-get_cart_items_count get_cart_items_count
  27. *
  28. * @code bx_srv('system', 'get_cart_items_count', [], 'TemplPaymentsServices'); @endcode
  29. * @code {{~system:get_cart_items_count:TemplPaymentsServices~}} @endcode
  30. *
  31. * Get number of items in shopping cart for currently logged in profile.
  32. *
  33. * @see BxBasePaymentsServices::serviceGetChartStats
  34. */
  35. /**
  36. * @ref bx_system_general-get_cart_items_count "get_cart_items_count"
  37. */
  38. public function serviceGetCartItemsCount()
  39. {
  40. return BxDolPayments::getInstance()->getCartItemsCount();
  41. }
  42. /**
  43. * @page service Service Calls
  44. * @section bx_system_general System Services
  45. * @subsection bx_system_general-payments Payments
  46. * @subsubsection bx_system_general-get_orders_count get_orders_count
  47. *
  48. * @code bx_srv('system', 'get_orders_count', ["new"], 'TemplPaymentsServices'); @endcode
  49. * @code {{~system:get_orders_count:TemplPaymentsServices["new"]~}} @endcode
  50. *
  51. * Get number of order by type for currently logged in profile.
  52. * @param $sType type, for example: new
  53. *
  54. * @see BxBasePaymentsServices::serviceGetOrdersCount
  55. */
  56. /**
  57. * @ref bx_system_general-get_orders_count "get_orders_count"
  58. */
  59. public function serviceGetOrdersCount($sType)
  60. {
  61. return BxDolPayments::getInstance()->getOrdersCount($sType);
  62. }
  63. public function serviceGetLiveUpdatesCart($aMenuItemParent, $aMenuItemChild, $iCount = 0)
  64. {
  65. $iCountNew = BxDolPayments::getInstance()->getCartItemsCount();
  66. if($iCountNew == $iCount)
  67. return false;
  68. return array(
  69. 'count' => $iCountNew, // required
  70. 'method' => 'bx_menu_show_live_update(oData)', // required
  71. 'data' => array(
  72. 'code' => BxDolTemplate::getInstance()->parseHtmlByTemplateName('menu_item_addon', array(
  73. 'content' => '{count}'
  74. )),
  75. 'mi_parent' => $aMenuItemParent,
  76. 'mi_child' => $aMenuItemChild
  77. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  78. );
  79. }
  80. public function serviceGetLiveUpdatesOrders($aMenuItemParent, $aMenuItemChild, $iCount = 0)
  81. {
  82. $iCountNew = BxDolPayments::getInstance()->getOrdersCount('new');
  83. if($iCountNew == $iCount)
  84. return false;
  85. return array(
  86. 'count' => $iCountNew, // required
  87. 'method' => 'bx_menu_show_live_update(oData)', // required
  88. 'data' => array(
  89. 'code' => BxDolTemplate::getInstance()->parseHtmlByTemplateName('menu_item_addon', array(
  90. 'content' => '{count}'
  91. )),
  92. 'mi_parent' => $aMenuItemParent,
  93. 'mi_child' => $aMenuItemChild
  94. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  95. );
  96. }
  97. }
  98. /** @} */