BxBaseModPaymentOrders.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 BasePayment Base classes for Payment like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModPaymentOrders extends BxDol
  12. {
  13. protected $MODULE;
  14. protected $_oModule;
  15. function __construct()
  16. {
  17. parent::__construct();
  18. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  19. }
  20. /**
  21. * @page service Service Calls
  22. * @section bx_base_payment Base Payment
  23. * @subsection bx_base_payment-integration Integration
  24. * @subsubsection bx_base_payment-get_orders_url get_orders_url
  25. *
  26. * @code bx_srv('bx_payment', 'get_orders_url', [...], 'Orders'); @endcode
  27. *
  28. * Get orders page URL.
  29. *
  30. * @return string with orders page URL.
  31. *
  32. * @see BxBaseModPaymentOrders::serviceGetOrdersUrl
  33. */
  34. /**
  35. * @ref bx_base_payment-get_orders_url "get_orders_url"
  36. */
  37. public function serviceGetOrdersUrl()
  38. {
  39. if(!$this->_oModule->isLogged())
  40. return '';
  41. return $this->_oModule->_oConfig->getUrl('URL_ORDERS');
  42. }
  43. /**
  44. * @page service Service Calls
  45. * @section bx_base_payment Base Payment
  46. * @subsection bx_base_payment-integration Integration
  47. * @subsubsection bx_base_payment-get_orders_count get_orders_count
  48. *
  49. * @code bx_srv('bx_payment', 'get_orders_count', [...], 'Orders'); @endcode
  50. *
  51. * Get processed orders count by type.
  52. *
  53. * @param $sType string value with type. For now 'new' type is available only.
  54. * @param $iProfileId (optional) integer value with profile ID. If empty value is provided then currently logged in profile will be used.
  55. * @return integer value with orders count.
  56. *
  57. * @see BxBaseModPaymentOrders::serviceGetOrdersCount
  58. */
  59. /**
  60. * @ref bx_base_payment-get_orders_count "get_orders_count"
  61. */
  62. public function serviceGetOrdersCount($sType, $iProfileId = 0)
  63. {
  64. if(!in_array($sType, array('new')))
  65. return 0;
  66. $iProfileId = !empty($iProfileId) ? $iProfileId : $this->_oModule->getProfileId();
  67. if(empty($iProfileId))
  68. return 0;
  69. $aOrders = $this->_oModule->_oDb->getOrderProcessed(array('type' => $sType, 'seller_id' => $iProfileId));
  70. if(empty($aOrders) || !is_array($aOrders))
  71. return 0;
  72. return count($aOrders);
  73. }
  74. }
  75. /** @} */