Back to Opencart

File catalog\model\catalog\subscription_plan.php

docs/api/source-catalog.model.catalog.subscription_plan.html

4.1.0.36.0 KB
Original Source

Namespaces

Classes

| 1: | <?php | | 2: | namespace Opencart\Catalog\Model\Catalog; | | 3: | /** | | 4: | * Class Subscription Plan | | 5: | * | | 6: | * @package Opencart\Catalog\Model\Catalog | | 7: | */ | | 8: | class SubscriptionPlan extends \Opencart\System\Engine\Model { | | 9: | /** | | 10: | * Get Subscription Plan | | 11: | * | | 12: | * @param int $subscription_plan_id | | 13: | * | | 14: | * @return array<string, mixed> | | 15: | */ | | 16: | public function getSubscriptionPlan(int $subscription_plan_id): array { | | 17: | $query = $this->db->query("SELECT * FROM " . DB\_PREFIX . "subscription\_plan sp LEFT JOIN " . DB\_PREFIX . "subscription\_plan\_description spd ON (sp.subscription\_plan\_id = spd.subscription\_plan\_id) WHERE sp.subscription\_plan\_id = '" . (int)$subscription_plan_id . "' AND spd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); | | 18: | | | 19: | return $query->row; | | 20: | } | | 21: | | | 22: | /** | | 23: | * Get Subscription Plans | | 24: | * | | 25: | * @param array<string, mixed> $data | | 26: | * | | 27: | * @return array<int, array<string, mixed>> | | 28: | */ | | 29: | public function getSubscriptionPlans(array $data = []): array { | | 30: | $sql = "SELECT * FROM " . DB\_PREFIX . "subscription\_plan sp LEFT JOIN " . DB\_PREFIX . "subscription\_plan\_description spd ON (sp.subscription\_plan\_id = spd.subscription\_plan\_id) WHERE spd.language\_id = '" . (int)$this->config->get('config_language_id') . "'"; | | 31: | | | 32: | if (!empty($data['filter_name'])) { | | 33: | $sql .= " AND spd.name LIKE '" . $this->db->escape($data['filter_name'] . '%') . "'"; | | 34: | } | | 35: | | | 36: | $sort_data = [ | | 37: | 'spd.name', | | 38: | 'sp.sort_order' | | 39: | ]; | | 40: | | | 41: | if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { | | 42: | $sql .= " ORDER BY " . $data['sort']; | | 43: | } else { | | 44: | $sql .= " ORDER BY spd.name"; | | 45: | } | | 46: | | | 47: | if (isset($data['order']) && ($data['order'] == 'DESC')) { | | 48: | $sql .= " DESC"; | | 49: | } else { | | 50: | $sql .= " ASC"; | | 51: | } | | 52: | | | 53: | if (isset($data['start']) || isset($data['limit'])) { | | 54: | if ($data['start'] < 0) { | | 55: | $data['start'] = 0; | | 56: | } | | 57: | | | 58: | if ($data['limit'] < 1) { | | 59: | $data['limit'] = 20; | | 60: | } | | 61: | | | 62: | $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; | | 63: | } | | 64: | | | 65: | $query = $this->db->query($sql); | | 66: | | | 67: | return $query->rows; | | 68: | } | | 69: | | | 70: | /** | | 71: | * Get Total Subscription Plans | | 72: | * | | 73: | * @return int | | 74: | */ | | 75: | public function getTotalSubscriptionPlans(): int { | | 76: | $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB\_PREFIX . "subscription\_plan"); | | 77: | | | 78: | return (int)$query->row['total']; | | 79: | } | | 80: | } | | 81: | |

OpenCart API API documentation generated by ApiGen dev-master