本文整理汇总了PHP中edd_get_shop_country函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_shop_country函数的具体用法?PHP edd_get_shop_country怎么用?PHP edd_get_shop_country使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_shop_country函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_get_tax_rate
/**
* Get taxation rate
*
* @since 1.3.3
* @param bool $country
* @param bool $state
* @return mixed|void
*/
function edd_get_tax_rate($country = false, $state = false)
{
$rate = (double) edd_get_option('tax_rate', 0);
$user_address = edd_get_customer_address();
if (empty($country)) {
if (!empty($_POST['billing_country'])) {
$country = $_POST['billing_country'];
} elseif (is_user_logged_in() && !empty($user_address)) {
$country = $user_address['country'];
}
$country = !empty($country) ? $country : edd_get_shop_country();
}
if (empty($state)) {
if (!empty($_POST['state'])) {
$state = $_POST['state'];
} elseif (!empty($_POST['card_state'])) {
$state = $_POST['card_state'];
} elseif (is_user_logged_in() && !empty($user_address)) {
$state = $user_address['state'];
}
$state = !empty($state) ? $state : edd_get_shop_state();
}
if (!empty($country)) {
$tax_rates = edd_get_tax_rates();
if (!empty($tax_rates)) {
// Locate the tax rate for this country / state, if it exists
foreach ($tax_rates as $key => $tax_rate) {
if ($country != $tax_rate['country']) {
continue;
}
if (!empty($tax_rate['global'])) {
if (!empty($tax_rate['rate'])) {
$rate = number_format($tax_rate['rate'], 4);
}
} else {
if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) {
continue;
}
$state_rate = $tax_rate['rate'];
if (0 !== $state_rate || !empty($state_rate)) {
$rate = number_format($state_rate, 4);
}
}
}
}
}
if ($rate > 1) {
// Convert to a number we can use
$rate = $rate / 100;
}
return apply_filters('edd_tax_rate', $rate, $country, $state);
}
示例2: edd_get_shop_states
/**
* Get Shop States
*
* @since 1.6
*
* @param null $country
* @return mixed|void A list of states for the shop's base country
*/
function edd_get_shop_states($country = null)
{
global $edd_options;
if (empty($country)) {
$country = edd_get_shop_country();
}
switch ($country) {
case 'US':
$states = edd_get_states_list();
break;
case 'CA':
$states = edd_get_provinces_list();
break;
case 'AU':
$states = edd_get_australian_states_list();
break;
case 'BR':
$states = edd_get_brazil_states_list();
break;
case 'CN':
$states = edd_get_chinese_states_list();
break;
case 'HK':
$states = edd_get_hong_kong_states_list();
break;
case 'HU':
$states = edd_get_hungary_states_list();
break;
case 'ID':
$states = edd_get_indonesian_states_list();
break;
case 'IN':
$states = edd_get_indian_states_list();
break;
case 'MY':
$states = edd_get_malaysian_states_list();
break;
case 'NZ':
$states = edd_get_new_zealand_states_list();
break;
case 'TH':
$states = edd_get_thailand_states_list();
break;
case 'ZA':
$states = edd_get_south_african_states_list();
break;
default:
$states = array();
break;
}
return apply_filters('edd_shop_states', $states);
}
示例3: edd_wallet_process_incentive
function edd_wallet_process_incentive()
{
if ($_REQUEST['gateway'] == 'wallet') {
EDD()->session->set('wallet_has_incentives', '1');
} else {
EDD()->session->set('wallet_has_incentives', null);
}
// Refresh the cart
if (empty($_POST['billing_country'])) {
$_POST['billing_country'] = edd_get_shop_country();
}
ob_start();
edd_checkout_cart();
$cart = ob_get_clean();
$response = array('html' => $cart, 'tax_raw' => edd_get_cart_tax(), 'tax' => html_entity_decode(edd_cart_tax(false), ENT_COMPAT, 'UTF-8'), 'tax_rate_raw' => edd_get_tax_rate(), 'tax_rate' => html_entity_decode(edd_get_formatted_tax_rate(), ENT_COMPAT, 'UTF-8'), 'total' => html_entity_decode(edd_cart_total(false), ENT_COMPAT, 'UTF-8'), 'total_raw' => edd_get_cart_total());
echo json_encode($response);
edd_die();
}
示例4: edd_default_cc_address_fields
//.........这里部分代码省略.........
}
?>
" placeholder="<?php
_e('Zip / Postal code', 'edd');
?>
" value="<?php
echo $customer['address']['zip'];
?>
"/>
</p>
<p id="edd-card-country-wrap">
<label for="billing_country" class="edd-label">
<?php
_e('Billing Country', 'edd');
?>
<?php
if (edd_field_is_required('billing_country')) {
?>
<span class="edd-required-indicator">*</span>
<?php
}
?>
</label>
<span class="edd-description"><?php
_e('The country for your billing address.', 'edd');
?>
</span>
<select name="billing_country" id="billing_country" class="billing_country edd-select<?php
if (edd_field_is_required('billing_country')) {
echo ' required';
}
?>
">
<?php
$selected_country = edd_get_shop_country();
if (!empty($customer['address']['country']) && '*' !== $customer['address']['country']) {
$selected_country = $customer['address']['country'];
}
$countries = edd_get_country_list();
foreach ($countries as $country_code => $country) {
echo '<option value="' . esc_attr($country_code) . '"' . selected($country_code, $selected_country, false) . '>' . $country . '</option>';
}
?>
</select>
</p>
<p id="edd-card-state-wrap">
<label for="card_state" class="edd-label">
<?php
_e('Billing State / Province', 'edd');
?>
<?php
if (edd_field_is_required('card_state')) {
?>
<span class="edd-required-indicator">*</span>
<?php
}
?>
</label>
<span class="edd-description"><?php
_e('The state or province for your billing address.', 'edd');
?>
</span>
<?php
$selected_state = edd_get_shop_state();
$states = edd_get_shop_states($selected_country);
if (!empty($customer['address']['state'])) {
$selected_state = $customer['address']['state'];
}
if (!empty($states)) {
?>
<select name="card_state" id="card_state" class="card_state edd-select<?php
if (edd_field_is_required('card_state')) {
echo ' required';
}
?>
">
<?php
foreach ($states as $state_code => $state) {
echo '<option value="' . $state_code . '"' . selected($state_code, $selected_state, false) . '>' . $state . '</option>';
}
?>
</select>
<?php
} else {
?>
<input type="text" size="6" name="card_state" id="card_state" class="card_state edd-input" placeholder="<?php
_e('State / Province', 'edd');
?>
"/>
<?php
}
?>
</p>
<?php
do_action('edd_cc_billing_bottom');
?>
</fieldset>
<?php
echo ob_get_clean();
}
示例5: edd_ajax_get_states_field
/**
* Retrieve a states drop down
*
* @since 1.6
* @return void
*/
function edd_ajax_get_states_field()
{
if (empty($_POST['country'])) {
$_POST['country'] = edd_get_shop_country();
}
$states = edd_get_shop_states($_POST['country']);
if (!empty($states)) {
$args = array('name' => $_POST['field_name'], 'id' => $_POST['field_name'], 'class' => $_POST['field_name'] . ' edd-select', 'options' => $states, 'show_option_all' => false, 'show_option_none' => false);
$response = EDD()->html->select($args);
} else {
$response = 'nostates';
}
echo $response;
edd_die();
}
示例6: load_scripts
/**
* Load javascript files and localized variables
*
* @access public
* @since 2.4
* @return void
*/
public function load_scripts()
{
if (!edd_is_checkout()) {
return;
}
$test_mode = edd_is_test_mode();
$seller_id = edd_get_option('amazon_seller_id', '');
$client_id = edd_get_option('amazon_client_id', '');
$default_amazon_scope = array('profile', 'postal_code', 'payments:widget');
if (edd_use_taxes()) {
$default_amazon_scope[] = 'payments:shipping_address';
}
$default_amazon_button_settings = array('type' => 'PwA', 'color' => 'Gold', 'size' => 'medium', 'scope' => implode(' ', $default_amazon_scope), 'popup' => true);
$amazon_button_settings = apply_filters('edd_amazon_button_settings', $default_amazon_button_settings);
$base_url = '';
$sandbox = $test_mode ? 'sandbox/' : '';
switch (edd_get_shop_country()) {
case 'GB':
$base_url = 'https://static-eu.payments-amazon.com/OffAmazonPayments/uk/' . $sandbox . 'lpa/';
break;
case 'DE':
$base_url = 'https://static-eu.payments-amazon.com/OffAmazonPayments/de/' . $sandbox . 'lpa/';
break;
default:
$base_url = 'https://static-na.payments-amazon.com/OffAmazonPayments/us/' . $sandbox;
break;
}
if (!empty($base_url)) {
$url = $base_url . 'js/Widgets.js?sellerId=' . $seller_id;
wp_enqueue_script('edd-amazon-widgets', $url, array('jquery'), null, false);
wp_localize_script('edd-amazon-widgets', 'edd_amazon', apply_filters('edd_amazon_checkout_vars', array('sellerId' => $seller_id, 'clientId' => $client_id, 'referenceID' => $this->reference_id, 'buttonType' => $amazon_button_settings['type'], 'buttonColor' => $amazon_button_settings['color'], 'buttonSize' => $amazon_button_settings['size'], 'scope' => $amazon_button_settings['scope'], 'popup' => $amazon_button_settings['popup'], 'checkoutUri' => $this->get_amazon_checkout_uri(), 'redirectUri' => $this->get_amazon_authenticate_redirect(), 'signinUri' => $this->get_amazon_signin_redirect())));
}
}
示例7: get_registration_url
/**
* Retrieve the URL for connecting Amazon account to EDD
*
* @access public
* @since 2.4
* @return string
*/
private function get_registration_url()
{
switch (edd_get_shop_country()) {
case 'GB':
$base_url = 'https://payments.amazon.co.uk/preregistration/lpa';
break;
case 'DE':
$base_url = 'https://payments.amazon.de/preregistration/lpa';
break;
default:
$base_url = 'https://sellercentral.amazon.com/hz/me/sp/signup';
break;
}
$query_args = array('solutionProviderId' => 'A3JST9YM1SX7LB', 'marketplaceId' => 'AGWSWK15IEJJ7', 'solutionProviderToken' => 'AAAAAQAAAAEAAAAQnngerc8vYweGDt8byl2smgAAAHBgMm923quugHaGmPi%2B3sqo93TSL1aKwU85v71Zh7EXVK8De%2FuahjCFHft3cxN3rwAF4Iwg03sDW0jnkLULmFk7M1Fr69IV2XF477m0kU1EM0Z%2FbQssHdLai%2Fzoce1jZVmw8So3F2jhiDyfTHUK2AYP', 'solutionProviderOptions' => 'lwa%3Bmws-acc%3B');
return add_query_arg($query_args, $base_url);
}
示例8: edd_get_shop_states
/**
* Get Shop States
*
* @since 1.6
*
* @param null $country
* @return mixed|void A list of states for the shop's base country
*/
function edd_get_shop_states($country = null)
{
if (empty($country)) {
$country = edd_get_shop_country();
}
switch ($country) {
case 'US':
$states = edd_get_states_list();
break;
case 'CA':
$states = edd_get_provinces_list();
break;
case 'AU':
$states = edd_get_australian_states_list();
break;
case 'BD':
$states = edd_get_bangladeshi_states_list();
break;
case 'BG':
$states = edd_get_bulgarian_states_list();
break;
case 'BR':
$states = edd_get_brazil_states_list();
break;
case 'CN':
$states = edd_get_chinese_states_list();
break;
case 'HK':
$states = edd_get_hong_kong_states_list();
break;
case 'HU':
$states = edd_get_hungary_states_list();
break;
case 'ID':
$states = edd_get_indonesian_states_list();
break;
case 'IN':
$states = edd_get_indian_states_list();
break;
case 'IR':
$states = edd_get_iranian_states_list();
break;
case 'IT':
$states = edd_get_italian_states_list();
break;
case 'JP':
$states = edd_get_japanese_states_list();
break;
case 'MX':
$states = edd_get_mexican_states_list();
break;
case 'MY':
$states = edd_get_malaysian_states_list();
break;
case 'NP':
$states = edd_get_nepalese_states_list();
break;
case 'NZ':
$states = edd_get_new_zealand_states_list();
break;
case 'PE':
$states = edd_get_peruvian_states_list();
break;
case 'TH':
$states = edd_get_thailand_states_list();
break;
case 'TR':
$states = edd_get_turkey_states_list();
break;
case 'ZA':
$states = edd_get_south_african_states_list();
break;
case 'ES':
$states = edd_get_spain_states_list();
break;
default:
$states = array();
break;
}
return apply_filters('edd_shop_states', $states);
}