Permalink
Browse files

MINOR: Renamed EcommerceRole to ShopMember. Clarified in glossary.

  • Loading branch information...
1 parent bf5ad6d commit 69940b1d26f4ce9d65ae8a51ef3ea29cca926227 @jedateach jedateach committed Apr 23, 2012
View
@@ -3,7 +3,7 @@
define('SHOP_DIR','shop');
// Extend the Member with e-commerce related fields.
-DataObject::add_extension('Member', 'EcommerceRole');
+DataObject::add_extension('Member', 'ShopMember');
// Extend Payment with e-commerce relationship.
if(!class_exists('Payment')) user_error("You need to also install the Payment module to use the eCommerce module", E_USER_ERROR);
DataObject::add_extension('Payment', 'EcommercePayment');
View
@@ -63,7 +63,7 @@ protected function findOrMake(){
//otherwise start a new order
$order = new Order();
$order->SessionID = session_id();
- if(EcommerceRole::get_associate_to_current_order()){
+ if(ShopMember::get_associate_to_current_order()){
$order->MemberID = Member::currentUserID(); // Set the Member relation to this order
}
$order->write();
View
@@ -34,7 +34,7 @@ function __construct($controller, $name) {
$order = ShoppingCart::current_order();
if($order && $order->UseShippingAddress) {
- $countryField = new DropdownField('ShippingCountry', _t('OrderForm.Country','Country'), Geoip::getCountryDropDown(), EcommerceRole::find_country());
+ $countryField = new DropdownField('ShippingCountry', _t('OrderForm.Country','Country'), Geoip::getCountryDropDown(), ShopMember::find_country());
$shippingFields = new CompositeField(
new HeaderField(_t('OrderForm.SendGoodsToDifferentAddress','Send goods to different address'), 3),
new LiteralField('ShippingNote', '<p class="message warning">'._t('OrderForm.ShippingNote','Your goods will be sent to the address below.').'</p>'),
@@ -261,12 +261,12 @@ function processOrder($data, $form, $request) {
if(!$member){
if(self::$user_membership_optional){
if($this->userWantsToBecomeMember($data,$form)){
- $member = EcommerceRole::ecommerce_create_or_merge($data);
+ $member = ShopMember::ecommerce_create_or_merge($data);
}
//otherwise we assume they don't want to become a member
}elseif(self::$force_membership){
//create member
- $member = EcommerceRole::ecommerce_create_or_merge($data);
+ $member = ShopMember::ecommerce_create_or_merge($data); //create member
}
}
View
@@ -878,13 +878,12 @@ protected function sendEmail($emailClass, $copyToAdmin = true) {
*/
function findShippingCountry($codeOnly = false) {
if(!$this->ID) {
- $country = ShoppingCart::has_country() ? ShoppingCart::get_country() : EcommerceRole::find_country();
+ $country = ShoppingCart::has_country() ? ShoppingCart::get_country() : ShopMember::find_country();
}
elseif(!$this->UseShippingAddress || !$country = $this->ShippingCountry) {
- $country = EcommerceRole::find_country();
+ $country = ShopMember::find_country();
}
-
- return $codeOnly ? $country : EcommerceRole::find_country_title($country);
+ return $codeOnly ? $country : ShopMember::find_country_title($country);
}
@@ -1,20 +1,19 @@
<?php
/**
- * EcommerceRole provides customisations to the {@link Member}
- * class specifically for this ecommerce module.
+ * ShopMember provides customisations to {@link Member} for shop purposes
*
* @package shop
*/
-class EcommerceRole extends DataObjectDecorator {
+class ShopMember extends DataObjectDecorator {
- protected static $group_name = "Shop Customers";
+ protected static $group_name = "Customers";
static function set_group_name($v) {self::$group_name = $v;}
static function get_group_name(){return self::$group_name;}
- protected static $associate_to_current_order = false;
- static function associate_to_current_order($associate = true){self::$associate_to_current_order = $associate;}
- static function get_associate_to_current_order(){return self::$associate_to_current_order;}
-
+ protected static $login_joins_cart = false;
+ static function associate_to_current_order($join = true){self::$login_joins_cart = $join;}
+ static function get_associate_to_current_order(){ return self::$login_joins_cart; }
+
function extraStatics() {
return array(
'db' => array(
@@ -31,26 +30,24 @@ function extraStatics() {
}
/**
- * Member login hook
+ * Link the current order to the current member, if there is one.
*/
function memberLoggedIn(){
- if(self::$associate_to_current_order && ShoppingCart::order_started() && $order = ShoppingCart::current_order()){
+ if(self::$login_joins_cart && $order = ShoppingCart::singleton()->current()){
$order->MemberID = $this->owner->ID;
$order->write();
}
}
+ /**
+ * Clear the cart, and session variables.
+ */
function memberLoggedOut(){
- if(self::$associate_to_current_order){
- ShoppingCart::clear();
+ if(self::$login_joins_cart){
+ ShoppingCart::singleton()->clear();
}
}
- static function findCountryTitle($code) {
- user_error("deprecated, please use EcommerceRole::find_country_title", E_USER_NOTICE);
- return self::find_country_title($code);
- }
-
static function find_country_title($code) {
$countries = Geoip::getCountryDropDown();
// check if code was provided, and is found in the country array
@@ -61,18 +58,6 @@ static function find_country_title($code) {
}
}
- /**
- * Find the member's country.
- *
- * If there is no member logged in, try to resolve
- * their IP address to a country.
- *
- * @return string Found country of member
- */
- static function findCountry() {
- user_error("deprecated, please use EcommerceRole::find_country", E_USER_NOTICE);
- return self::find_country();
- }
static function find_country() {
$member = Member::currentUser();
@@ -81,7 +66,6 @@ static function find_country() {
} else {
if($country = ShoppingCart::get_country())
return $country;
-
// HACK Avoid CLI tests from breaking (GeoIP gets in the way of unbiased tests!)
// @todo Introduce a better way of disabling GeoIP as needed (Geoip::disable() ?)
if(Director::is_cli()) {
@@ -93,70 +77,16 @@ static function find_country() {
return $country;
}
-
- static function add_members_to_customer_group() {
- $gp = DataObject::get_one("Group", "\"Title\" = '".self::get_group_name()."'");
- if(!$gp) {
- $gp = new Group();
- $gp->Title = self::get_group_name();
- $gp->Sort = 999998; //TODO: explain why?
- $gp->write();
- }
- $allCombos = DB::query("
- SELECT \"Group_Members\".\"ID\", \"Group_Members\".\"MemberID\", \"Group_Members\".\"GroupID\"
- FROM \"Group_Members\"
- WHERE \"Group_Members\".\"GroupID\" = ".$gp->ID.";"
- );
- //make an array of all combos
- $alreadyAdded = array();
- $alreadyAdded[-1] = -1;
- if($allCombos) {
- foreach($allCombos as $combo) {
- $alreadyAdded[$combo["MemberID"]] = $combo["MemberID"];
- }
- }
- $unlistedMembers = DataObject::get(
- "Member",
- $where = "\"Member\".\"ID\" NOT IN (".implode(",",$alreadyAdded).")",
- $sort = null,
- $join = "INNER JOIN \"Order\" ON \"Order\".\"MemberID\" = \"Member\".\"ID\""
- );
-
- //add combos
- if($unlistedMembers) {
- $existingMembers = $gp->Members();
- foreach($unlistedMembers as $member) {
- $existingMembers->add($member);
- }
- }
- }
-
- /**
- * Create a new member with given data for a new member,
- * or merge the data into the logged in member.
- *
- * IMPORTANT: Before creating a new Member record, we first
- * check that the request email address doesn't already exist.
- *
- * @param array $data Form request data to update the member with
- * @return boolean|object Member object or boolean FALSE
- */
- public static function createOrMerge($data) {
- user_error("deprecated, please use EcommerceRole::ecommerce_create_or_merge", E_USER_NOTICE);
- return self::ecommerce_create_or_merge($data);
-
- }
+
public static function ecommerce_create_or_merge($data) {
- // Because we are using a ConfirmedPasswordField, the password will
- // be an array of two fields
+ // Because we are using a ConfirmedPasswordField, the password will be an array of two fields
if(isset($data['Password']) && is_array($data['Password'])) {
$data['Password'] = $data['Password']['_Password'];
}
// We need to ensure that the unique field is never overwritten
$uniqueField = Member::get_unique_identifier_field();
if(isset($data[$uniqueField])) {
$SQL_unique = Convert::raw2xml($data[$uniqueField]);
- // TODO review - should $uniqueField be quoted by Member::get_unique_identifier_field() already? (this would be sapphire bug)
$existingUniqueMember = DataObject::get_one('Member', "\"$uniqueField\" = '{$SQL_unique}'");
if($existingUniqueMember && $existingUniqueMember->exists()) {
if(Member::currentUserID() != $existingUniqueMember->ID) {
@@ -184,17 +114,17 @@ function updateCMSFields($fields) {
*/
function getEcommerceFields() {
$fields = new FieldSet(
- new HeaderField(_t('EcommerceRole.PERSONALINFORMATION','Personal Information'), 3),
- new TextField('FirstName', _t('EcommerceRole.FIRSTNAME','First Name')),
- new TextField('Surname', _t('EcommerceRole.SURNAME','Surname')),
- new TextField('HomePhone', _t('EcommerceRole.HOMEPHONE','Phone')),
- new TextField('MobilePhone', _t('EcommerceRole.MOBILEPHONE','Mobile')),
- new EmailField('Email', _t('EcommerceRole.EMAIL','Email')),
- new TextField('Address', _t('EcommerceRole.ADDRESS','Address')),
- new TextField('AddressLine2', _t('EcommerceRole.ADDRESSLINE2','&nbsp;')),
- new TextField('City', _t('EcommerceRole.CITY','City')),
- new TextField('PostalCode', _t('EcommerceRole.POSTALCODE','Postal Code')),
- new DropdownField('Country', _t('EcommerceRole.COUNTRY','Country'), Geoip::getCountryDropDown(), self::find_country())
+ new HeaderField(_t('ShopMember.PERSONALINFORMATION','Personal Information'), 3),
+ new TextField('FirstName', _t('ShopMember.FIRSTNAME','First Name')),
+ new TextField('Surname', _t('ShopMember.SURNAME','Surname')),
+ new TextField('HomePhone', _t('ShopMember.HOMEPHONE','Phone')),
+ new TextField('MobilePhone', _t('ShopMember.MOBILEPHONE','Mobile')),
+ new EmailField('Email', _t('ShopMember.EMAIL','Email')),
+ new TextField('Address', _t('ShopMember.ADDRESS','Address')),
+ new TextField('AddressLine2', _t('ShopMember.ADDRESSLINE2','&nbsp;')),
+ new TextField('City', _t('ShopMember.CITY','City')),
+ new TextField('PostalCode', _t('ShopMember.POSTALCODE','Postal Code')),
+ new DropdownField('Country', _t('ShopMember.COUNTRY','Country'), Geoip::getCountryDropDown(), self::find_country())
);
$this->owner->extend('augmentEcommerceFields', $fields);
return $fields;
@@ -221,13 +151,56 @@ function getEcommerceRequiredFields() {
public function CountryTitle() {
return self::find_country_title($this->owner->Country);
+ }
+
+ //deprecated functions
+
+ /**
+ * @deprecated - use CustomersToGroupTask
+ */
+ static function add_members_to_customer_group() {}
+
+ /**
+ * @deprecated
+ * @param unknown_type $code
+ */
+ static function findCountryTitle($code) {
+ user_error("deprecated, please use ShopMember::find_country_title", E_USER_NOTICE);
+ return self::find_country_title($code);
+ }
+ /**
+ * Find the member's country.
+ *
+ * If there is no member logged in, try to resolve
+ * their IP address to a country.
+ * @deprecated
+ * @return string Found country of member
+ */
+ static function findCountry() {
+ user_error("deprecated, please use ShopMember::find_country", E_USER_NOTICE);
+ return self::find_country();
}
-
- //this method needs to be tested!
- public function onAfterWrite() {
- parent::onAfterWrite();
- self::add_members_to_customer_group();
+
+ /**
+ * Create a new member with given data for a new member,
+ * or merge the data into the logged in member.
+ *
+ * IMPORTANT: Before creating a new Member record, we first
+ * check that the request email address doesn't already exist.
+ *
+ * @deprecated
+ * @param array $data Form request data to update the member with
+ * @return boolean|object Member object or boolean FALSE
+ */
+ public static function createOrMerge($data) {
+ user_error("deprecated, please use ShopMember::ecommerce_create_or_merge", E_USER_NOTICE);
+ return self::ecommerce_create_or_merge($data);
+
}
+}
-}
+/**
+ * @deprecated use ShopMember
+ */
+class EcommerceRole extends ShopMember{}
@@ -57,7 +57,7 @@ function Rate(){
}
protected function Country() {
- return EcommerceRole::find_country();
+ return ShopMember::find_country();
}
function TableTitle() {
@@ -7,10 +7,10 @@ class CustomersToGroupTask extends BuildTask{
function run($request){
- $gp = DataObject::get_one("Group", "\"Title\" = '".self::get_group_name()."'");
+ $gp = DataObject::get_one("Group", "\"Title\" = '".ShopMember::get_group_name()."'");
if(!$gp) {
$gp = new Group();
- $gp->Title = Customer::get_group_name();
+ $gp->Title = ShopMember::get_group_name();
$gp->write();
}
$allCombos = DB::query("
View
@@ -2,14 +2,18 @@
This page explains verious terms used in the documentation.
+## Visitor
+
+A person who visits the website.
+
## Customer
-Someone who visits and/or purchases from an eCommerce website.
+A visitor who places an order on an ecommerce website.
## Member
-Someone who has a login to see order history, etc.
+A visitor who has a login to see order history, etc.
## Guest
-Someone who does not want to save member details.
+A visitor who does not want to save member details.
View
@@ -50,7 +50,7 @@
ExpiryDateField::set_short_months(true); //uses short months (e.g. Jan instead of january) for credit card expiry date.
//MEMBER
-EcommerceRole::set_group_name("Customers");
+ShopMember::set_group_name("ShopMembers");
//MODIFIERS
FlatTaxModifier::set_tax("0.15", "GST", $exclusive = false);
View
@@ -81,17 +81,17 @@
$lang['de_DE']['CheckoutPage_OrderSuccessful.ss']['SUCCESSFULl'] = 'Bestellung erfolgreich durchgeführt';
$lang['de_DE']['ChequePayment']['MESSAGE'] = 'Bezahlung per Scheck (Vorkasse). Bitte beachten: Der Versand der Produkte erfolgt erst nach Zahlungseingang.';
$lang['de_DE']['DataReport']['EXPORTCSV'] = 'Export als CSV';
-$lang['de_DE']['EcommerceRole']['PERSONALINFORMATION'] = 'Ihre Daten';
-$lang['de_DE']['EcommerceRole']['COUNTRY'] = 'Land';
-$lang['de_DE']['EcommerceRole']['FIRSTNAME'] = 'Vorname';
-$lang['de_DE']['EcommerceRole']['SURNAME'] = 'Nachname';
-$lang['de_DE']['EcommerceRole']['HOMEPHONE'] = 'Tel.';
-$lang['de_DE']['EcommerceRole']['MOBILEPHONE'] = 'Mobil';
-$lang['de_DE']['EcommerceRole']['EMAIL'] = 'Email';
-$lang['de_DE']['EcommerceRole']['ADDRESS'] = 'Adresse';
-$lang['de_DE']['EcommerceRole']['ADDRESSLINE2'] = '&nbsp;';
-$lang['de_DE']['EcommerceRole']['CITY'] = 'Stadt';
-$lang['de_DE']['EcommerceRole']['POSTALCODE'] = 'PLZ';
+$lang['de_DE']['ShopMember']['PERSONALINFORMATION'] = 'Ihre Daten';
+$lang['de_DE']['ShopMember']['COUNTRY'] = 'Land';
+$lang['de_DE']['ShopMember']['FIRSTNAME'] = 'Vorname';
+$lang['de_DE']['ShopMember']['SURNAME'] = 'Nachname';
+$lang['de_DE']['ShopMember']['HOMEPHONE'] = 'Tel.';
+$lang['de_DE']['ShopMember']['MOBILEPHONE'] = 'Mobil';
+$lang['de_DE']['ShopMember']['EMAIL'] = 'Email';
+$lang['de_DE']['ShopMember']['ADDRESS'] = 'Adresse';
+$lang['de_DE']['ShopMember']['ADDRESSLINE2'] = '&nbsp;';
+$lang['de_DE']['ShopMember']['CITY'] = 'Stadt';
+$lang['de_DE']['ShopMember']['POSTALCODE'] = 'PLZ';
$lang['de_DE']['EcomQuantityField.ss']['ADDONE'] = '1 &quot;%s&quot; zum Warenkorb hinzufügen';
$lang['de_DE']['EcomQuantityField.ss']['REMOVEONE'] = '1 &quot;%s&quot; aus dem Warenkorb entfernen';
$lang['de_DE']['FindOrderReport']['DATERANGE'] = 'Zeitraum';
Oops, something went wrong.

0 comments on commit 69940b1

Please sign in to comment.