本文整理汇总了PHP中ShopFunctions::getCountryIDByName方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopFunctions::getCountryIDByName方法的具体用法?PHP ShopFunctions::getCountryIDByName怎么用?PHP ShopFunctions::getCountryIDByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShopFunctions
的用法示例。
在下文中一共展示了ShopFunctions::getCountryIDByName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countryData
/**
* @static
* @param $method
* @param $country
* @return array|null
*/
static function countryData($method, $country)
{
$countriesData = self::countriesData();
$lower_country = strtolower($country);
if (array_key_exists(strtoupper($country), $countriesData)) {
$cData = $countriesData[strtoupper($country)];
$eid = 'klarna_merchantid_' . $lower_country;
$secret = 'klarna_sharedsecret_' . $lower_country;
$invoice_fee = 'klarna_invoicefee_' . $lower_country;
$min_amount = 'klarna_min_amount_part_' . $lower_country;
$payment_activated = 'klarna_payments_' . $lower_country;
$active = 'klarna_active_' . $lower_country;
$cData['eid'] = $method->{$eid};
$cData['secret'] = $method->{$secret};
$cData['invoice_fee'] = (double) $method->{$invoice_fee};
$cData['country_code_3'] = $country;
$cData['virtuemart_currency_id'] = ShopFunctions::getCurrencyIDByName($cData['currency_code']);
$cData['virtuemart_country_id'] = ShopFunctions::getCountryIDByName($country);
$cData['mode'] = KlarnaHandler::getKlarnaMode($method, $country);
$cData['min_amount'] = $method->{$min_amount};
$cData['active'] = $method->{$active};
if (empty($method->{$payment_activated})) {
$method->{$payment_activated} = array('invoice', 'part');
}
$cData['payments_activated'] = $method->{$payment_activated};
if (!class_exists('VirtueMartModelVendor')) {
require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
}
$vendor_id = 1;
$cData['vendor_currency'] = VirtueMartModelVendor::getVendorCurrency($vendor_id)->vendor_currency;
return $cData;
} else {
return NULL;
}
}
示例2: countryData
static function countryData($method, $country)
{
$countriesData = self::countriesData();
$lower_country = strtolower($country);
if (array_key_exists(strtoupper($country), $countriesData)) {
$cData = $countriesData[strtoupper($country)];
$eid = 'klarna_merchantid_' . $lower_country;
$secret = 'klarna_sharedsecret_' . $lower_country;
$invoice_fee = 'klarna_invoicefee_' . $lower_country;
$min_amount = 'klarna_min_amount_part_' . $lower_country;
$active = 'klarna_active_' . $lower_country;
$cData['eid'] = $method->{$eid};
$cData['secret'] = $method->{$secret};
$cData['invoice_fee'] = (double) $method->{$invoice_fee};
$cData['country_code_3'] = $country;
$cData['virtuemart_currency_id'] = ShopFunctions::getCurrencyIDByName($cData['currency_code']);
$cData['virtuemart_country_id'] = ShopFunctions::getCountryIDByName($country);
$cData['mode'] = $method->klarna_mode;
$cData['min_amount'] = $method->{$min_amount};
$cData['active'] = $method->{$active};
return $cData;
} else {
return NULL;
}
}
示例3: plgVmOnSelectCheckPayment
/**
* This event is fired after the payment method has been selected. It can be used to store
* additional payment info in the cart.
* @author Valérie isaksen
*
* @param VirtueMartCart $cart: the actual cart
* @return null if the payment was not selected, true if the data is valid, error message if the data is not vlaid
*
*/
public function plgVmOnSelectCheckPayment(VirtueMartCart $cart)
{
if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) {
return NULL;
// Another method was selected, do nothing
}
if (!($method = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) {
return NULL;
// Another method was selected, do nothing
}
if (!class_exists('KlarnaAddr')) {
require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'klarnaaddr.php';
}
$session = JFactory::getSession();
$sessionKlarna = new stdClass();
//$post = JRequest::get('post');
$klarnaData_paymentmethod = JRequest::getVar('klarna_paymentmethod', '');
if ($klarnaData_paymentmethod == 'klarna_invoice') {
$klarnaData_payment = "klarna_invoice";
$sessionKlarna->klarna_option = 'invoice';
} elseif ($klarnaData_paymentmethod == 'klarna_partPayment') {
$klarnaData_payment = "klarna_partpay";
$sessionKlarna->klarna_option = 'part';
} elseif ($klarnaData_paymentmethod == 'klarna_speccamp') {
$klarnaData_payment = "klarna_speccamp";
$sessionKlarna->klarna_option = 'spec';
} else {
return NULL;
}
// Store payment_method_id so we can activate the
// right payment in case something goes wrong.
$sessionKlarna->virtuemart_payment_method_id = $cart->virtuemart_paymentmethod_id;
$sessionKlarna->klarna_paymentmethod = $klarnaData_paymentmethod;
$this->_getCartAddressCountryCode($cart, $country3, $countryId, 'country_3_code');
// $country2= strtolower($country2);
if (empty($country3)) {
$country3 = "SWE";
$countryId = ShopFunctions::getCountryIDByName($country3);
}
$cData = KlarnaHandler::countryData($method, strtoupper($country3));
$klarnaData = KlarnaHandler::getDataFromEditPayment();
$klarnaData['country'] = $cData['country_code'];
//$country = $cData['country_code']; //KlarnaHandler::convertCountry($method, $country2);
//$lang = $cData['language_code']; //KlarnaHandler::getLanguageForCountry($method, $country);
// Get the correct data
//Removes spaces, tabs, and other delimiters.
// If it is a swedish customer we use the information from getAddress
if (strtolower($cData['country_code']) == "se") {
if (empty($klarnaData['socialNumber'])) {
VmInfo('VMPAYMENT_KLARNA_MUST_VALID_PNO');
return false;
}
$swedish_addresses = klarnaHandler::getAddresses($klarnaData['socialNumber'], $cData, $method);
if (empty($swedish_addresses)) {
VmInfo('VMPAYMENT_KLARNA_NO_GETADDRESS');
return false;
}
//This example only works for GA_GIVEN.
foreach ($swedish_addresses as $address) {
if ($address->isCompany) {
$klarnaData['company_name'] = $address->getCompanyName();
} else {
$klarnaData['first_name'] = $address->getFirstName();
$klarnaData['last_name'] = $address->getLastName();
}
$klarnaData['street'] = $address->getStreet();
$klarnaData['zip'] = $address->getZipCode();
$klarnaData['city'] = $address->getCity();
$klarnaData['country'] = $address->getCountryCode();
$countryId = $klarnaData['virtuemart_country_id'] = shopFunctions::getCountryIDByName($klarnaData['country']);
}
foreach ($klarnaData as $key => $value) {
$klarnaData[$key] = mb_convert_encoding($klarnaData[$key], 'UTF-8', 'ISO-8859-1');
}
} elseif (!KlarnaHandler::checkDataFromEditPayment($klarnaData)) {
//VmInfo('VMPAYMENT_KLARNA_MISSING_DATA');
//return false;
}
$st = $this->getCartAddress($cart, $address_type, true);
if ($address_type == 'BT') {
$prefix = '';
} else {
$prefix = 'shipto_';
}
// Update the Shipping Address to what is specified in the register.
$update_data = array($prefix . 'address_type_name' => 'Klarna', $prefix . 'company' => $klarnaData['company_name'], $prefix . 'first_name' => $klarnaData['first_name'], $prefix . 'middle_name' => $st['middle_name'], $prefix . 'last_name' => $klarnaData['last_name'], $prefix . 'address_1' => $klarnaData['street'], $prefix . 'address_2' => $klarnaData['house_ext'], $prefix . 'house_no' => $klarnaData['house_no'], $prefix . 'zip' => html_entity_decode($klarnaData['zip']), $prefix . 'city' => $klarnaData['city'], $prefix . 'virtuemart_country_id' => $countryId, $prefix . 'state' => '', $prefix . 'phone_1' => $klarnaData['phone'], $prefix . 'phone_2' => $st['phone_2'], $prefix . 'fax' => $st['fax'], $prefix . 'birthday' => empty($klarnaData['birthday']) ? $st['birthday'] : $klarnaData['birthday'], $prefix . 'social_number' => empty($klarnaData['pno']) ? $klarnaData['socialNumber'] : $klarnaData['pno'], 'address_type' => $address_type);
if ($address_type == 'BT') {
$update_data['email'] = $klarnaData['email'];
}
// save address in cart if different
// if (false) {
//.........这里部分代码省略.........
示例4: checkConditions
/**
* Check if the payment conditions are fulfilled for this payment method
*
* @author: Valerie Isaksen
*
* @param $cart_prices : cart prices
* @param $payment
* @return true: if the conditions are fulfilled, false otherwise
*
*/
protected function checkConditions($cart, $method, $cart_prices)
{
$this->convert_condition_amount($method);
$amount = $this->getCartAmount($cart_prices);
$address = $cart->ST == 0 ? $cart->BT : $cart->ST;
$amount_cond = ($amount >= $method->min_amount and $amount <= $method->max_amount or $method->min_amount <= $amount and $method->max_amount == 0);
$countries[0] = ShopFunctions::getCountryIDByName('NL');
// probably did not gave his BT:ST address
if (!is_array($address)) {
$address = array();
$address['virtuemart_country_id'] = 0;
}
if (!isset($address['virtuemart_country_id'])) {
$address['virtuemart_country_id'] = 0;
}
if (in_array($address['virtuemart_country_id'], $countries) || count($countries) == 0) {
if ($amount_cond) {
return TRUE;
}
}
return FALSE;
}
示例5: storeAddresses
function storeAddresses()
{
$this->cart = VirtueMartCart::getCart();
$addressST = $addressBT = array();
if ($this->response['SHIPTONAME'] == $this->response['FIRSTNAME'] . ' ' . $this->response['LASTNAME']) {
$firstName = $this->response['FIRSTNAME'];
$lastName = $this->response['LASTNAME'];
} else {
$shipToName = explode(' ', $this->response['SHIPTONAME']);
$firstName = $shipToName[0];
$lastName = '';
if (count($shipToName) > 1) {
$lastName = str_replace($firstName . ' ', '', $this->response['SHIPTONAME']);
}
}
$usersModel = VmModel::getModel('user');
$validateUserData = $usersModel->validateUserData($this->cart->BT, 'BT');
if ($validateUserData !== true) {
$addressBT['email'] = $this->response['EMAIL'];
$addressBT['first_name'] = $firstName;
$addressBT['last_name'] = $lastName;
$addressBT['address_1'] = $this->response['SHIPTOSTREET'];
$addressBT['city'] = $this->response['SHIPTOCITY'];
$addressBT['zip'] = $this->response['SHIPTOZIP'];
$addressBT['virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']);
$addressBT['virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']);
$this->cart->saveAddressInCart($addressBT, 'BT', true);
}
$addressST['shipto_address_type_name'] = 'PayPal Account';
$addressST['shipto_first_name'] = $firstName;
$addressST['shipto_last_name'] = $lastName;
$addressST['shipto_address_1'] = $this->response['SHIPTOSTREET'];
$addressST['shipto_city'] = $this->response['SHIPTOCITY'];
$addressST['shipto_zip'] = $this->response['SHIPTOZIP'];
$addressST['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']);
$addressST['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']);
$this->cart->STsameAsBT = 0;
$this->cart->setCartIntoSession();
$this->cart->saveAddressInCart($addressST, 'ST', true);
}
示例6: display
//.........这里部分代码省略.........
$adminIdUser = JFactory::getUser($this->adminID);
if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) {
$this->allowChangeShopper = true;
}
}
}
}
if ($this->allowChangeShopper) {
$this->userList = $this->getUserList();
}
$task = $input->getString("vmtask");
if (file_exists(dirname(__FILE__) . "/" . $task . ".php")) {
require_once dirname(__FILE__) . "/" . $task . ".php";
}
if ($task == "completecheckout") {
require_once dirname(__FILE__) . "/updatecartaddress.php";
$checkout = $cart->checkoutData(false);
$app = JFactory::getApplication();
$messageQueue = $app->getMessageQueue();
$return_error = "";
if (count($messageQueue) > 0) {
foreach ($messageQueue as $message) {
$return_error .= $message['message'];
}
}
$returnarray = array();
if ($checkout) {
$returnarray["success"] = 1;
} else {
$returnarray["success"] = 0;
}
$returnarray['message'] = $return_error;
echo json_encode($returnarray);
exit;
}
if ($task == "ajaxshipment") {
$this->lSelectShipment();
echo json_encode($this->shipments_shipment_rates);
exit;
}
if ($task == "ajaxpayment") {
$this->lSelectPayment();
echo json_encode($this->paymentplugins_payments);
exit;
}
if ($task == "setsession") {
$payid = JRequest::getVar("payid", 0);
if ($payid > 0) {
$cart->setPaymentMethod(false, false, $payid);
$cart->setCartIntoSession();
}
echo "success";
exit;
}
if ($task == "klarnaupdate") {
$post = JRequest::get("post");
$address = array();
$address['shipto_address_type_name'] = 'ST';
if (!empty($post['given_name'])) {
$address['shipto_first_name'] = $post['given_name'];
}
if (!empty($post['family_name'])) {
$address['shipto_last_name'] = $post['family_name'];
}
if (!empty($post['street_address'])) {
$address['shipto_address_1'] = $post['street_address'];
}
if (!empty($post['street_address2'])) {
$address['shipto_address_2'] = $post['street_address2'];
}
if (!empty($post['postal_code'])) {
$address['shipto_zip'] = $post['postal_code'];
}
if (!empty($post['city'])) {
$address['shipto_city'] = $post['city'];
}
if (!empty($post['country'])) {
$address['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($post['country']);
} else {
if (!empty($cart->BT['virtuemart_country_id'])) {
$address['shipto_virtuemart_country_id'] = $cart->BT['virtuemart_country_id'];
}
}
if (!empty($post['region'])) {
$address['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($post['region']);
}
if (!empty($post['phone'])) {
$address['shipto_phone_1'] = $post['phone'];
}
$address['tos'] = 1;
$cart->saveAddressInCart($address, 'ST', true, 'shipto_');
$cart->setCartIntoSession(false, true);
$return = array();
$return['response'] = "success";
echo json_encode($return);
exit;
}
$cart->setCartIntoSession();
parent::display($tpl);
}