Skip to content

Commit

Permalink
Merge branch 'feature/php-cs-fixer' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	api/Coupons.php
  • Loading branch information
osben committed Sep 12, 2016
2 parents e8ed669 + a37dc10 commit 4172930
Show file tree
Hide file tree
Showing 106 changed files with 12,061 additions and 12,284 deletions.
69 changes: 35 additions & 34 deletions ajax/cart.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
<?php
session_start();
require_once('../api/Simpla.php');

class CartAjax extends Simpla
{
public function fetch()
{
$this->cart->add_item($this->request->get('variant', 'integer'), $this->request->get('amount', 'integer'));
$cart = $this->cart->get_cart();
$this->design->assign('cart', $cart);

$currencies = $this->money->get_currencies(array('enabled'=>1));
if(isset($_SESSION['currency_id']))
$currency = $this->money->get_currency($_SESSION['currency_id']);
else
$currency = reset($currencies);

$this->design->assign('currency', $currency);

return $this->design->fetch('cart_informer.tpl');
}
}

$cart_ajax = new CartAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
<?php
session_start();
require_once('../api/Simpla.php');

class CartAjax extends Simpla
{
public function fetch()
{
$this->cart->add_item($this->request->get('variant', 'integer'), $this->request->get('amount', 'integer'));
$cart = $this->cart->get_cart();
$this->design->assign('cart', $cart);

$currencies = $this->money->get_currencies(array('enabled'=>1));
if (isset($_SESSION['currency_id'])) {
$currency = $this->money->get_currency($_SESSION['currency_id']);
} else {
$currency = reset($currencies);
}

$this->design->assign('currency', $currency);

return $this->design->fetch('cart_informer.tpl');
}
}

$cart_ajax = new CartAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
109 changes: 54 additions & 55 deletions ajax/search_products.php
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
<?php
require_once('../api/Simpla.php');

class SearchProductsAjax extends Simpla
{
private $limit = 30;
public function fetch()
{
$result = new stdClass;
$result->suggestions = array();
$result->query = $this->request->get('query', 'string');

if(!empty($result->query))
{
$kw = $this->db->escape($result->query);

$this->db->query("SELECT p.id, p.name, i.filename as image FROM __products p
LEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1)
WHERE (p.name LIKE '%$kw%' OR p.meta_keywords LIKE '%$kw%' OR p.id in (SELECT product_id FROM __variants WHERE sku LIKE '%$kw%'))
AND visible=1
GROUP BY p.id
ORDER BY p.name
LIMIT ?", $this->limit);
$products = $this->db->results();

$suggestions = array();

foreach($products as $product)
{
$suggestion = new stdClass();

if(!empty($product->image))
$product->image = $this->design->resize_modifier($product->image, 35, 35);

$suggestion->value = $product->name;
$suggestion->data = $product;
$result->suggestions[] = $suggestion;
}
}


return $result;
}
}

$cart_ajax = new SearchProductsAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex, noarchive, nosnippet");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
<?php
require_once('../api/Simpla.php');

class SearchProductsAjax extends Simpla
{
private $limit = 30;
public function fetch()
{
$result = new stdClass;
$result->suggestions = array();
$result->query = $this->request->get('query', 'string');

if (!empty($result->query)) {
$kw = $this->db->escape($result->query);

$this->db->query("SELECT p.id, p.name, i.filename as image FROM __products p
LEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1)
WHERE (p.name LIKE '%$kw%' OR p.meta_keywords LIKE '%$kw%' OR p.id in (SELECT product_id FROM __variants WHERE sku LIKE '%$kw%'))
AND visible=1
GROUP BY p.id
ORDER BY p.name
LIMIT ?", $this->limit);
$products = $this->db->results();

$suggestions = array();

foreach ($products as $product) {
$suggestion = new stdClass();

if (!empty($product->image)) {
$product->image = $this->design->resize_modifier($product->image, 35, 35);
}

$suggestion->value = $product->name;
$suggestion->data = $product;
$result->suggestions[] = $suggestion;
}
}


return $result;
}
}

$cart_ajax = new SearchProductsAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex, noarchive, nosnippet");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
Loading

0 comments on commit 4172930

Please sign in to comment.