Back to Opencart

File catalog\model\checkout\voucher_theme.php

docs/api/source-catalog.model.checkout.voucher_theme.html

4.1.0.35.5 KB
Original Source

Namespaces

Classes

| 1: | <?php | | 2: | namespace Opencart\Catalog\Model\Checkout; | | 3: | /** | | 4: | * Class VoucherTheme | | 5: | * | | 6: | * @package Opencart\Catalog\Model\Checkout | | 7: | */ | | 8: | class VoucherTheme extends \Opencart\System\Engine\Model { | | 9: | /** | | 10: | * Get Voucher Theme | | 11: | * | | 12: | * @param int $voucher_theme_id | | 13: | * | | 14: | * @return array<string, mixed> | | 15: | */ | | 16: | public function getVoucherTheme(int $voucher_theme_id): array { | | 17: | $query = $this->db->query("SELECT * FROM " . DB\_PREFIX . "voucher\_theme vt LEFT JOIN " . DB\_PREFIX . "voucher\_theme\_description vtd ON (vt.voucher\_theme\_id = vtd.voucher\_theme\_id) WHERE vt.voucher\_theme\_id = '" . (int)$voucher_theme_id . "' AND vtd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); | | 18: | | | 19: | return $query->row; | | 20: | } | | 21: | | | 22: | /** | | 23: | * Get Voucher Themes | | 24: | * | | 25: | * @param array<string, mixed> $data | | 26: | * | | 27: | * @return array<int, array<string, mixed>> | | 28: | */ | | 29: | public function getVoucherThemes(array $data = []): array { | | 30: | $sql = "SELECT * FROM " . DB\_PREFIX . "voucher\_theme vt LEFT JOIN " . DB\_PREFIX . "voucher\_theme\_description vtd ON (vt.voucher\_theme\_id = vtd.voucher\_theme\_id) WHERE vtd.language\_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.name"; | | 31: | | | 32: | if (isset($data['order']) && ($data['order'] == 'DESC')) { | | 33: | $sql .= " DESC"; | | 34: | } else { | | 35: | $sql .= " ASC"; | | 36: | } | | 37: | | | 38: | if (isset($data['start']) || isset($data['limit'])) { | | 39: | if ($data['start'] < 0) { | | 40: | $data['start'] = 0; | | 41: | } | | 42: | | | 43: | if ($data['limit'] < 1) { | | 44: | $data['limit'] = 20; | | 45: | } | | 46: | | | 47: | $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; | | 48: | } | | 49: | | | 50: | $key = md5($sql); | | 51: | | | 52: | $voucher_theme_data = $this->cache->get('voucher_theme.' . $key); | | 53: | | | 54: | if (!$voucher_theme_data) { | | 55: | $query = $this->db->query($sql); | | 56: | | | 57: | $voucher_theme_data = $query->rows; | | 58: | | | 59: | $this->cache->set('voucher_theme.' . $key, $voucher_theme_data); | | 60: | } | | 61: | | | 62: | return $voucher_theme_data; | | 63: | } | | 64: | } | | 65: | |

OpenCart API API documentation generated by ApiGen dev-master