[+] Core : added a boolean in the database (guest/cart/order) in order to know if the customer used the mobile theme for the order

This commit is contained in:
Damien Metzger
2013-02-28 15:23:21 +01:00
parent a753bfc23e
commit 8b2e9fb08e
9 changed files with 57 additions and 12 deletions
+10 -6
View File
@@ -59,6 +59,9 @@ class CartCore extends ObjectModel
/** @var string Gift message if specified */
public $gift_message;
/** @var boolean Mobile Theme */
public $mobile_theme;
/** @var string Object creation date */
public $date_add;
@@ -109,6 +112,7 @@ class CartCore extends ObjectModel
'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'gift_message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'),
'mobile_theme' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'delivery_option' => array('type' => self::TYPE_STRING),
'secure_key' => array('type' => self::TYPE_STRING, 'size' => 32),
'allow_seperated_package' =>array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
@@ -119,12 +123,12 @@ class CartCore extends ObjectModel
protected $webserviceParameters = array(
'fields' => array(
'id_address_delivery' => array('xlink_resource' => 'addresses'),
'id_address_invoice' => array('xlink_resource' => 'addresses'),
'id_currency' => array('xlink_resource' => 'currencies'),
'id_customer' => array('xlink_resource' => 'customers'),
'id_guest' => array('xlink_resource' => 'guests'),
'id_lang' => array('xlink_resource' => 'languages'),
'id_address_delivery' => array('xlink_resource' => 'addresses'),
'id_address_invoice' => array('xlink_resource' => 'addresses'),
'id_currency' => array('xlink_resource' => 'currencies'),
'id_customer' => array('xlink_resource' => 'customers'),
'id_guest' => array('xlink_resource' => 'guests'),
'id_lang' => array('xlink_resource' => 'languages'),
),
'associations' => array(
'cart_rows' => array('resource' => 'cart_row', 'virtual_entity' => true, 'fields' => array(
+18 -2
View File
@@ -111,7 +111,7 @@ class ContextCore
$this->mobile_device = false;
if ($this->checkMobileContext())
{
if(isset(Context::getContext()->cookie->no_mobile) && Context::getContext()->cookie->no_mobile == false AND (int)Configuration::get('PS_ALLOW_MOBILE_DEVICE') != 0)
if (isset(Context::getContext()->cookie->no_mobile) && Context::getContext()->cookie->no_mobile == false AND (int)Configuration::get('PS_ALLOW_MOBILE_DEVICE') != 0)
$this->mobile_device = true;
else
{
@@ -143,9 +143,25 @@ class ContextCore
{
// Check mobile context
if (Tools::isSubmit('no_mobile_theme'))
{
Context::getContext()->cookie->no_mobile = true;
else if (Tools::isSubmit('mobile_theme_ok'))
if (Context::getContext()->cookie->id_guest)
{
$guest = new Guest(Context::getContext()->cookie->id_guest);
$guest->mobile_theme = false;
$guest->update();
}
}
elseif (Tools::isSubmit('mobile_theme_ok'))
{
Context::getContext()->cookie->no_mobile = false;
if (Context::getContext()->cookie->id_guest)
{
$guest = new Guest(Context::getContext()->cookie->id_guest);
$guest->mobile_theme = true;
$guest->update();
}
}
return isset($_SERVER['HTTP_USER_AGENT'])
&& isset(Context::getContext()->cookie)
+3 -1
View File
@@ -40,6 +40,7 @@ class GuestCore extends ObjectModel
public $real_player;
public $windows_media;
public $accept_language;
public $mobile_theme;
/**
* @see ObjectModel::$definition
@@ -62,6 +63,7 @@ class GuestCore extends ObjectModel
'real_player' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'windows_media' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'accept_language' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 8),
'mobile_theme' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
),
);
@@ -77,7 +79,7 @@ class GuestCore extends ObjectModel
$acceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$this->id_operating_system = $this->getOs($userAgent);
$this->id_web_browser = $this->getBrowser($userAgent);
$this->accept_language = $this->getLanguage($acceptLanguage);
$this->mobile_theme = Context::getContext()->getMobileDevice();
}
protected function getLanguage($acceptLanguage)
+1
View File
@@ -227,6 +227,7 @@ abstract class PaymentModuleCore extends Module
$order->recyclable = $this->context->cart->recyclable;
$order->gift = (int)$this->context->cart->gift;
$order->gift_message = $this->context->cart->gift_message;
$order->mobile_theme = $this->context->cart->mobile_theme;
$order->conversion_rate = $this->context->currency->conversion_rate;
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, 2) : $amount_paid;
$order->total_paid_real = 0;
+4
View File
@@ -75,6 +75,9 @@ class OrderCore extends ObjectModel
/** @var string Gift message if specified */
public $gift_message;
/** @var boolean Mobile Theme */
public $mobile_theme;
/**
* @var string Shipping number
* @deprecated 1.5.0.4
@@ -176,6 +179,7 @@ class OrderCore extends ObjectModel
'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'gift_message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'),
'mobile_theme' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'total_discounts' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'total_discounts_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'total_discounts_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),