public static function insertDefaultData() { $loyaltyModule = new Loyalty(); $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $default = new LoyaltyStateModule(LoyaltyStateModule::getDefaultId()); $default->name[$defaultLanguage] = $loyaltyModule->getL('Awaiting validation'); $default->save(); $validation = new LoyaltyStateModule(LoyaltyStateModule::getValidationId()); $validation->id_order_state = _PS_OS_DELIVERED_; $validation->name[$defaultLanguage] = $loyaltyModule->getL('Available'); $validation->save(); $cancel = new LoyaltyStateModule(LoyaltyStateModule::getCancelId()); $cancel->id_order_state = _PS_OS_CANCELED_; $cancel->name[$defaultLanguage] = $loyaltyModule->getL('Canceled'); $cancel->save(); $convert = new LoyaltyStateModule(LoyaltyStateModule::getConvertId()); $convert->name[$defaultLanguage] = $loyaltyModule->getL('Already converted'); $convert->save(); $noneAward = new LoyaltyStateModule(LoyaltyStateModule::getNoneAwardId()); $noneAward->name[$defaultLanguage] = $loyaltyModule->getL('Unavailable on discounts'); $noneAward->save(); return true; }
public static function insertDefaultData() { $loyaltyModule = new Loyalty(); $languages = Language::getLanguages(); $defaultTranslations = array('default' => array('id_loyalty_state' => (int) LoyaltyStateModule::getDefaultId(), 'default' => $loyaltyModule->getL('Awaiting validation'), 'en' => 'Awaiting validation', 'fr' => 'En attente de validation')); $defaultTranslations['validated'] = array('id_loyalty_state' => (int) LoyaltyStateModule::getValidationId(), 'id_order_state' => Configuration::get('PS_OS_DELIVERED'), 'default' => $loyaltyModule->getL('Available'), 'en' => 'Available', 'fr' => 'Disponible'); $defaultTranslations['cancelled'] = array('id_loyalty_state' => (int) LoyaltyStateModule::getCancelId(), 'id_order_state' => Configuration::get('PS_OS_CANCELED'), 'default' => $loyaltyModule->getL('Cancelled'), 'en' => 'Cancelled', 'fr' => 'Annulés'); $defaultTranslations['converted'] = array('id_loyalty_state' => (int) LoyaltyStateModule::getConvertId(), 'default' => $loyaltyModule->getL('Already converted'), 'en' => 'Already converted', 'fr' => 'Déjà convertis'); $defaultTranslations['none_award'] = array('id_loyalty_state' => (int) LoyaltyStateModule::getNoneAwardId(), 'default' => $loyaltyModule->getL('Unavailable on discounts'), 'en' => 'Unavailable on discounts', 'fr' => 'Non disponbile sur produits remisés'); foreach ($defaultTranslations as $loyaltyState) { $state = new LoyaltyStateModule((int) $loyaltyState['id_loyalty_state']); if (isset($loyaltyState['id_order_state'])) { $state->id_order_state = (int) $loyaltyState['id_order_state']; } $state->name[(int) Configuration::get('PS_LANG_DEFAULT')] = $loyaltyState['default']; foreach ($languages as $language) { if (isset($loyaltyState[$language['iso_code']])) { $state->name[(int) $language['id_lang']] = $loyaltyState[$language['iso_code']]; } } $state->save(); } return true; }
foreach ($ids_discount as $key => $discount) { $discounts[$key] = new Discount((int) $discount['id_cart_rule'], (int) $cookie->id_lang); $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount((int) $discount['id_cart_rule']); } } $allCategories = Category::getSimpleCategories((int) $cookie->id_lang); $voucherCategories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'); if ($voucherCategories != '' and $voucherCategories != 0) { $voucherCategories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); } else { die(Tools::displayError()); } if (sizeof($voucherCategories) == sizeof($allCategories)) { $categoriesNames = null; } else { $categoriesNames = array(); foreach ($allCategories as $k => $allCategory) { if (in_array($allCategory['id_category'], $voucherCategories)) { $categoriesNames[$allCategory['id_category']] = trim($allCategory['name']); } } if (!empty($categoriesNames)) { $categoriesNames = Tools::truncate(implode(', ', $categoriesNames), 100) . '.'; } else { $categoriesNames = null; } } $smarty->assign(array('nbDiscounts' => (int) $nbDiscounts, 'discounts' => $discounts, 'minimalLoyalty' => (double) Configuration::get('PS_LOYALTY_MINIMAL'), 'categories' => $categoriesNames)); $loyalty = new Loyalty(); echo $loyalty->display(dirname(__FILE__) . '/loyalty.php', 'loyalty.tpl'); include dirname(__FILE__) . '/../../footer.php';
* limitations under the License. */ /** * Set access token and include all required classes in the application. */ require_once 'header.php'; /** * This class contains utility functions to create request/response objects for * webservice api. */ require_once 'utils/wob_utils.php'; $wobPayload = new WobPayload($ORIGINS); $objId = strval(rand(1, 100)); switch ($_REQUEST['type']) { case 'loyalty': $loyaltyObject = Loyalty::generateLoyaltyObject(ISSUER_ID, LOYALTY_CLASS_ID, LOYALTY_OBJECT_ID . $objId); $wobPayload->addWalletObjects($loyaltyObject, LOYALTY_OBJECT_ID); break; case 'offer': $offerObject = Offer::generateOfferObject(ISSUER_ID, OFFER_CLASS_ID, OFFER_OBJECT_ID . $objId); $wobPayload->addWalletObjects($offerObject, OFFER_OBJECT_ID); break; case 'giftcard': $giftCardObject = GiftCard::generateGiftCardObject(ISSUER_ID, GIFTCARD_CLASS_ID, GIFTCARD_OBJECT_ID . $objId); $wobPayload->addWalletObjects($giftCardObject, GIFTCARD_OBJECT_ID); break; } // Save to wallet request body. $requestBody = $wobPayload->getSaveToWalletRequest(); // Create the response JWT. $utils = new WobUtils();
* Set webservice response.. */ require_once 'webservice/webservice_response.php'; // Create WobUilts object to handle requests. $utils = new WobUtils(); // Get webservice request object $inputJson = file_get_contents('php://input'); $input = json_decode($inputJson, TRUE); $requestObject = $utils->getWebserviceRequestObject($input); //Get linking id the merchant loyalty program account identification. $linkId = is_object($requestObject) ? $requestObject->getParams()->getLinkingId() : NULL; // Get api version from request object. $apiVersion = is_object($requestObject) ? $requestObject->getApiVersion() : '1.0'; // Create loyalty object based on linking id. $loyaltyObjectId = $linkId != NULL ? $linkId : LOYALTY_OBJECT_ID; $loyaltyObject = Loyalty::generateLoyaltyObject(ISSUER_ID, LOYALTY_CLASS_ID, $loyaltyObjectId); $firstName = $requestObject->getParams()->getWalletUser()->getFirstName(); $returnCode = strtoupper($firstName); if (is_object($loyaltyObject)) { // Handle signup and linking. $webResponse = new WebserviceResponse($returnCode); if (strpos($webResponse->getStatus(), ResponseCode::SUCCESS) !== false) { // Generate Web Service Response Body. $responseBody = $utils->generateWebserviceResponse($loyaltyObject, $webResponse, $apiVersion); } else { $errorAction = $linkId != NULL ? ResponseCode::ERROR_INVALID_LINKING_ID : ResponseCode::ERROR_ACCOUNT_ALREADY_LINKED; // For rejected sign-up/linking. $webResponse = new WebserviceResponse($errorAction); $invalidWalletUserFields = array('zipcode', 'phone'); $webResponse->setInvalidWalletUserFields($invalidWalletUserFields); // Generate Web Service Response Body.
/** * Copyright 2013 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Set access token and include all required classes in the application. */ require_once 'header.php'; switch ($_REQUEST['type']) { case 'loyalty': $service->loyaltyclass->insert(Loyalty::generateLoyaltyClass(ISSUER_ID, LOYALTY_CLASS_ID)); break; case 'offer': $service->offerclass->insert(Offer::generateOfferClass(ISSUER_ID, OFFER_CLASS_ID)); break; case 'giftcard': echo $service->giftcardclass->insert(GiftCard::generateGiftCardClass(ISSUER_ID, GIFTCARD_CLASS_ID)); break; }