OpenCart 🇺🇦

Класс Openbay { ... }

Название свойства Описание
Openbay::$registry private mixed $registry
Openbay::$installed_modules private mixed $installed_modules = array();
Тип Возвр. Описание
public mixed __construct ( $registry )
Исходный код метода:
$this->registry = $registry;
$this->ebay = new Ebay($registry);
$this->amazon = new Amazon($registry);
$this->amazonus = new Amazonus($registry);
public mixed __get ( $name )
Исходный код метода:
return $this->registry->get($name);
public mixed orderNew ( $order_id )
Исходный код метода:
/**
 * Once and order has been imported from external marketplace and
 * and order_id has been created, this method should be called.
 *
 */

// eBay Module
if ($this->config->get('openbay_status') == 1) {
	$this->ebay->orderNew($order_id);
}

// Amazon EU Module
if ($this->config->get('amazon_status') == 1) {
	$this->amazon->orderNew($order_id);
}

// Amazon US Module
if ($this->config->get('amazonus_status') == 1) {
	$this->amazonus->orderNew($order_id);
}

/**
 * If a 3rd party module needs to be notified about a new order
 * so it can update the stock then they should add a method to their
 * application here with the order id so they can get the info about it.
 * i.e. $this->mylibraryfile->newOrderMethod($order_id);
 */
public mixed productUpdateListen ( $productId, $data )
Исходный код метода:
/**
 * This call is performed after the product has been updated.
 * The $data variable holds all of the information that has
 * been sent through the $_POST.
 */

// eBay Module
if ($this->config->get('openbay_status') == 1) {
	$this->ebay->productUpdateListen($productId, $data);
}

// Amazon Module
if ($this->config->get('amazon_status') == 1) {
	$this->amazon->productUpdateListen($productId, $data);
}

// Amazon US Module
if ($this->config->get('amazonus_status') == 1) {
	$this->amazonus->productUpdateListen($productId, $data);
}
public mixed putStockUpdateBulk ( $productIdArray, $endInactive = false )
Исходный код метода:
/**
 * putStockUpdateBulk
 *
 * Takes an array of product id's where stock has been modified
 *
 * @param $productIdArray
 */

// eBay Module
if ($this->config->get('openbay_status') == 1) {
	$this->ebay->putStockUpdateBulk($productIdArray, $endInactive);
}

// Amazon EU Module
if ($this->config->get('amazon_status') == 1) {
	$this->amazon->putStockUpdateBulk($productIdArray, $endInactive);
}

// Amazon US Module
if ($this->config->get('amazonus_status') == 1) {
	$this->amazonus->putStockUpdateBulk($productIdArray, $endInactive);
}
public mixed testDbColumn ( $table, $column )
Исходный код метода:
//check profile table for default column
$res = $this->db->query("SHOW COLUMNS FROM `".DB_PREFIX.$table."` LIKE '".$column."'");
if($res->num_rows != 0) {
	return true;
}else{
	return false;
}
public mixed testDbTable ( $table )
Исходный код метода:
$res = $this->db->query("SELECT `table_name` AS `c` FROM `information_schema`.`tables` WHERE `table_schema` = DATABASE()");

$tables = array();

foreach($res->rows as $row) {
	$tables[] = $row['c'];
}

if(in_array($table, $tables)) {
	return true;
}else{
	return false;
}
public mixed splitName ( $name )
Исходный код метода:
$name = explode(' ', $name);
$fname = $name[0];
unset($name[0]);
$lname = implode(' ', $name);

return array(
	'firstname' => $fname,
	'surname'   => $lname
);
public mixed getTaxRates ( $tax_class_id )
Исходный код метода:
$tax_rates = array();

$tax_query = $this->db->query("SELECT
			tr2.tax_rate_id,
			tr2.name,
			tr2.rate,
			tr2.type,
			tr1.priority
		FROM " . DB_PREFIX . "tax_rule tr1
		LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id)
		INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id)
		LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id)
		LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id)
		WHERE tr1.tax_class_id = '" . (int)$tax_class_id . "'
		AND tr1.based = 'shipping'
		AND tr2cg.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'
		AND z2gz.country_id = '" . (int)$this->config->get('config_country_id') . "'
		AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$this->config->get('config_zone_id') . "')
		ORDER BY tr1.priority ASC");

foreach ($tax_query->rows as $result) {
	$tax_rates[$result['tax_rate_id']] = array(
		'tax_rate_id' => $result['tax_rate_id'],
		'name'        => $result['name'],
		'rate'        => $result['rate'],
		'type'        => $result['type'],
		'priority'    => $result['priority']
	);
}

return $tax_rates;
public mixed getTaxRate ( $class_id )
Исходный код метода:
$rates = $this->getTaxRates($class_id);
$percentage = 0.00;

foreach($rates as $rate) {
	if($rate['type'] == 'P') {
		$percentage += $rate['rate'];
	}
}

return $percentage;
public mixed getZoneId ( $name, $country_id )
Исходный код метода:
$query = $this->db->query("SELECT `zone_id` FROM `" . DB_PREFIX . "zone` WHERE `country_id` = '" . (int)$country_id . "' AND status = '1' AND `name` = '".$this->db->escape($name)."'");

if($query->num_rows > 0) {
	return $query->row['zone_id'];
}else{
	return 0;
}
public mixed newOrderAdminNotify ( $order_id, $order_status_id )
Исходный код метода:
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);

$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/order');

$order_status = $this->db->query("SELECT `name` FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "' LIMIT 1")->row['name'];

// Order Totals
$order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE `order_id` = '" . (int)$order_id . "' ORDER BY `sort_order` ASC");

//Order contents
$order_product_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_product` WHERE `order_id` = '" . (int)$order_id . "'");

$subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);

// Text
$text  = $language->get('text_new_received') . "\n\n";
$text .= $language->get('text_new_order_id') . ' ' . $order_info['order_id'] . "\n";
$text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
$text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
$text .= $language->get('text_new_products') . "\n";

foreach ($order_product_query->rows as $product) {
	$text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";

	$order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'");

	foreach ($order_option_query->rows as $option) {
		if ($option['type'] != 'file') {
			$value = $option['value'];
		} else {
			$value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.'));
		}

		$text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n";
	}
}

if(isset($order_voucher_query) && is_array($order_voucher_query)) {
	foreach ($order_voucher_query->rows as $voucher) {
		$text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']);
	}
}

$text .= "\n";
$text .= $language->get('text_new_order_total') . "\n";

foreach ($order_total_query->rows as $total) {
	$text .= $total['title'] . ': ' . html_entity_decode($total['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
}

$text .= "\n";

if ($order_info['comment']) {
	$text .= $language->get('text_new_comment') . "\n\n";
	$text .= $order_info['comment'] . "\n\n";
}

$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
$mail->send();

// Send to additional alert emails
$emails = explode(',', $this->config->get('config_alert_emails'));

foreach ($emails as $email) {
	if ($email && preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $email)) {
		$mail->setTo($email);
		$mail->send();
	}
}
public mixed deleteProduct ( $product_id )
Исходный код метода:
// eBay Module
if ($this->config->get('openbay_status') == 1) {
	$this->ebay->deleteProduct($product_id);
}

// Amazon Module
if ($this->config->get('amazon_status') == 1) {
	$this->amazon->deleteProduct($product_id);
}

// Amazon US Module
if ($this->config->get('amazonus_status') == 1) {
	$this->amazonus->deleteProduct($product_id);
}
public mixed deleteOrder ( $order_id )
Исходный код метода:
/**
 * Called when an order is deleted - usually by the admin. Helpful to loop over the products to add the stock back to the markets.
 */
// eBay Module
if ($this->config->get('openbay_status') == 1) {
	$this->ebay->deleteOrder($order_id);
}

// Amazon Module
if ($this->config->get('amazon_status') == 1) {
	$this->amazon->deleteOrder($order_id);
}

// Amazon US Module
if ($this->config->get('amazonus_status') == 1) {
	$this->amazonus->deleteOrder($order_id);
}
public mixed getProductModelNumber ( $product_id, $sku = null )
Исходный код метода:
if($sku != null) {
	$qry = $this->db->query("SELECT `sku` FROM `" . DB_PREFIX . "product_option_relation` WHERE `product_id` = '".(int)$product_id."' AND `var` = '".$this->db->escape($sku)."'");

	if($qry->num_rows > 0) {
		return $qry->row['sku'];
	}else{
		return false;
	}

}else{
	$qry = $this->db->query("SELECT `model` FROM `" . DB_PREFIX . "product` WHERE `product_id` = '".(int)$product_id."' LIMIT 1");

	if($qry->num_rows > 0) {
		return $qry->row['model'];
	}else{
		return false;
	}
}
public mixed addonLoad ( $addon )
Исходный код метода:
$addon = strtolower((string)$addon);

if (empty($this->installed_modules)) {
	$this->installed_modules = array();

	$rows = $this->db->query("SELECT `code` FROM " . DB_PREFIX . "extension")->rows;

	foreach ($rows as $row) {
		$this->installed_modules[] = strtolower($row['code']);
	}
}

return in_array($addon, $this->installed_modules);
public mixed getUserByEmail ( $email )
Исходный код метода:
$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer` WHERE `email` = '".$this->db->escape($email)."'");

if($qry->num_rows){
	return $qry->row['customer_id'];
}else{
	return false;
}
public mixed getProductOptions ( $product_id )
Исходный код метода:
$product_option_data = array();

$product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order");

foreach ($product_option_query->rows as $product_option) {
	if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
		$product_option_value_data = array();

		$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order");

		foreach ($product_option_value_query->rows as $product_option_value) {
			$product_option_value_data[] = array(
				'product_option_value_id' => $product_option_value['product_option_value_id'],
				'option_value_id'         => $product_option_value['option_value_id'],
				'name'                    => $product_option_value['name'],
				'image'                   => $product_option_value['image'],
				'quantity'                => $product_option_value['quantity'],
				'subtract'                => $product_option_value['subtract'],
				'price'                   => $product_option_value['price'],
				'price_prefix'            => $product_option_value['price_prefix'],
				'points'                  => $product_option_value['points'],
				'points_prefix'           => $product_option_value['points_prefix'],
				'weight'                  => $product_option_value['weight'],
				'weight_prefix'           => $product_option_value['weight_prefix']
			);
		}

		$product_option_data[] = array(
			'product_option_id'    => $product_option['product_option_id'],
			'option_id'            => $product_option['option_id'],
			'name'                 => $product_option['name'],
			'type'                 => $product_option['type'],
			'product_option_value' => $product_option_value_data,
			'required'             => $product_option['required']
		);
	} else {
		$product_option_data[] = array(
			'product_option_id' => $product_option['product_option_id'],
			'option_id'         => $product_option['option_id'],
			'name'              => $product_option['name'],
			'type'              => $product_option['type'],
			'option_value'      => $product_option['option_value'],
			'required'          => $product_option['required']
		);
	}
}

return $product_option_data;

Связанные классы:

Название класса Роль
class Config { ... } Компонент Config используется в данном классе
class Currency { ... } Компонент Currency используется в данном классе
class DB { ... } Компонент Db используется в данном классе

Комментарии