本文整理汇总了PHP中wc_get_endpoint_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_endpoint_url函数的具体用法?PHP wc_get_endpoint_url怎么用?PHP wc_get_endpoint_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_get_endpoint_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_edit_address_subscription_action
/**
* Add a "Change Shipping Address" button to the "My Subscriptions" table for those subscriptions
* which require shipping.
*
* @param array $all_actions The $subscription_key => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
* @param array $subscriptions All of a given users subscriptions that will be displayed on the "My Subscriptions" table
* @since 1.3
*/
public static function add_edit_address_subscription_action($all_actions, $subscriptions)
{
foreach ($all_actions as $subscription_key => $actions) {
$order = new WC_Order($subscriptions[$subscription_key]['order_id']);
$needs_shipping = false;
foreach ($order->get_items() as $item) {
if ($item['product_id'] !== $subscriptions[$subscription_key]['product_id']) {
continue;
}
$product = $order->get_product_from_item($item);
if (!is_object($product)) {
// In case a product has been deleted
continue;
}
if ($product->needs_shipping()) {
$needs_shipping = true;
}
}
if ($needs_shipping && in_array($subscriptions[$subscription_key]['status'], array('active', 'on-hold'))) {
// WC 2.1+
if (function_exists('wc_get_endpoint_url')) {
$all_actions[$subscription_key] = array('change_address' => array('url' => add_query_arg(array('subscription' => $subscription_key), wc_get_endpoint_url('edit-address', 'shipping')), 'name' => __('Change Address', 'woocommerce-subscriptions'))) + $all_actions[$subscription_key];
} else {
$all_actions[$subscription_key] = array('change_address' => array('url' => add_query_arg(array('address' => 'shipping', 'subscription' => $subscription_key), get_permalink(woocommerce_get_page_id('edit_address'))), 'name' => __('Change Address', 'woocommerce-subscriptions'))) + $all_actions[$subscription_key];
}
}
}
return $all_actions;
}
示例2: add_edit_address_subscription_action
/**
* Add a "Change Shipping Address" button to the "My Subscriptions" table for those subscriptions
* which require shipping.
*
* @param array $all_actions The $subscription_id => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
* @param array $subscriptions All of a given users subscriptions that will be displayed on the "My Subscriptions" table
* @since 1.3
*/
public static function add_edit_address_subscription_action($actions, $subscription)
{
if ($subscription->needs_shipping_address() && $subscription->has_status(array('active', 'on-hold'))) {
$actions['change_address'] = array('url' => add_query_arg(array('subscription' => $subscription->id), wc_get_endpoint_url('edit-address', 'shipping')), 'name' => __('Change Address', 'woocommerce-subscriptions'));
}
return $actions;
}
示例3: get_url
/**
* @param $page
*/
function get_url($page)
{
switch ($page) {
case 'sign_out':
return wc_get_endpoint_url('customer-logout', '', wc_get_page_permalink('myaccount'));
case 'edit_account_url':
return wc_customer_edit_account_url();
}
}
示例4: get_return_url
/**
* Get the return url (thank you page)
*
* @access public
* @param string $order (default: '')
* @return string
*/
public function get_return_url($order = '')
{
if ($order) {
$return_url = $order->get_checkout_order_received_url();
} else {
$return_url = wc_get_endpoint_url('order-received', '', get_permalink(wc_get_page_id('checkout')));
}
if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') {
$return_url = str_replace('http:', 'https:', $return_url);
}
return apply_filters('woocommerce_get_return_url', $return_url);
}
示例5: woocommerce_get_checkout_order_received_url
function woocommerce_get_checkout_order_received_url($order_received_url, $order_class)
{
if (defined('ICL_LANGUAGE_CODE')) {
$checkout_pid = wc_get_page_id('checkout');
if (!empty($_REQUEST['lang'])) {
if (function_exists('icl_object_id')) {
$checkout_pid = icl_object_id($checkout_pid, 'page', true, $_REQUEST['lang']);
}
}
$order_received_url = wc_get_endpoint_url('order-received', $order_class->id, get_permalink($checkout_pid));
if ('yes' == get_option('woocommerce_force_ssl_checkout') || is_ssl()) {
$order_received_url = str_replace('http:', 'https:', $order_received_url);
}
$order_received_url = add_query_arg('key', $order_class->order_key, $order_received_url);
return $order_received_url;
} else {
return $order_received_url;
}
}
示例6: save_address
/**
* Save and and update a billing or shipping address if the
* form was submitted through the user account page.
*/
public static function save_address()
{
global $wp;
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (empty($_POST['action']) || 'edit_address' !== $_POST['action'] || empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-edit_address')) {
return;
}
$user_id = get_current_user_id();
if ($user_id <= 0) {
return;
}
$load_address = isset($wp->query_vars['edit-address']) ? wc_edit_address_i18n(sanitize_title($wp->query_vars['edit-address']), true) : 'billing';
$address = WC()->countries->get_address_fields(esc_attr($_POST[$load_address . '_country']), $load_address . '_');
foreach ($address as $key => $field) {
if (!isset($field['type'])) {
$field['type'] = 'text';
}
// Get Value.
switch ($field['type']) {
case 'checkbox':
$_POST[$key] = (int) isset($_POST[$key]);
break;
default:
$_POST[$key] = isset($_POST[$key]) ? wc_clean($_POST[$key]) : '';
break;
}
// Hook to allow modification of value.
$_POST[$key] = apply_filters('woocommerce_process_myaccount_field_' . $key, $_POST[$key]);
// Validation: Required fields.
if (!empty($field['required']) && empty($_POST[$key])) {
wc_add_notice(sprintf(__('%s is a required field.', 'woocommerce'), $field['label']), 'error');
}
if (!empty($_POST[$key])) {
// Validation rules.
if (!empty($field['validate']) && is_array($field['validate'])) {
foreach ($field['validate'] as $rule) {
switch ($rule) {
case 'postcode':
$_POST[$key] = strtoupper(str_replace(' ', '', $_POST[$key]));
if (!WC_Validation::is_postcode($_POST[$key], $_POST[$load_address . '_country'])) {
wc_add_notice(__('Please enter a valid postcode / ZIP.', 'woocommerce'), 'error');
} else {
$_POST[$key] = wc_format_postcode($_POST[$key], $_POST[$load_address . '_country']);
}
break;
case 'phone':
$_POST[$key] = wc_format_phone_number($_POST[$key]);
if (!WC_Validation::is_phone($_POST[$key])) {
wc_add_notice(sprintf(__('%s is not a valid phone number.', 'woocommerce'), '<strong>' . $field['label'] . '</strong>'), 'error');
}
break;
case 'email':
$_POST[$key] = strtolower($_POST[$key]);
if (!is_email($_POST[$key])) {
wc_add_notice(sprintf(__('%s is not a valid email address.', 'woocommerce'), '<strong>' . $field['label'] . '</strong>'), 'error');
}
break;
}
}
}
}
}
do_action('woocommerce_after_save_address_validation', $user_id, $load_address, $address);
if (0 === wc_notice_count('error')) {
foreach ($address as $key => $field) {
update_user_meta($user_id, $key, $_POST[$key]);
}
wc_add_notice(__('Address changed successfully.', 'woocommerce'));
do_action('woocommerce_customer_save_address', $user_id, $load_address);
wp_safe_redirect(wc_get_endpoint_url('edit-address', '', wc_get_page_permalink('myaccount')));
exit;
}
}
示例7: wc_customer_edit_account_url
/**
* Get the link to the edit account details page.
*
* @return string
*/
function wc_customer_edit_account_url()
{
$edit_account_url = wc_get_endpoint_url('edit-account', '', wc_get_page_permalink('myaccount'));
return apply_filters('woocommerce_customer_edit_account_url', $edit_account_url);
}
示例8: wc_print_notices
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if (!defined('ABSPATH')) {
exit;
// Exit if accessed directly
}
wc_print_notices();
?>
<p class="myaccount_user">
<?php
// print_r($current_user);
printf(__('Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce') . ' ', $current_user->user_email, wc_get_endpoint_url('customer-logout', '', wc_get_page_permalink('myaccount')));
printf(__('From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce'), wc_customer_edit_account_url());
?>
</p>
<?php
do_action('woocommerce_before_my_account');
?>
<?php
wc_get_template('myaccount/my-downloads.php');
?>
<?php
wc_get_template('myaccount/my-orders.php', array('order_count' => $order_count));
?>
示例9: esc_url
<a class="woocommerce-Button woocommerce-Button--previous button" href="<?php
echo esc_url(wc_get_endpoint_url('orders', $current_page - 1));
?>
"><?php
_e('Previous', 'woocommerce');
?>
</a>
<?php
}
?>
<?php
if (intval($customer_orders->max_num_pages) !== $current_page) {
?>
<a class="woocommerce-Button woocommerce-Button--next button" href="<?php
echo esc_url(wc_get_endpoint_url('orders', $current_page + 1));
?>
"><?php
_e('Next', 'woocommerce');
?>
</a>
<?php
}
?>
</div>
<?php
}
?>
<?php
} else {
示例10: woocommerce_get_endpoint_url
/**
* @deprecated
*/
function woocommerce_get_endpoint_url($endpoint, $value = '', $permalink = '')
{
return wc_get_endpoint_url($endpoint, $value, $permalink);
}
示例11: nav_menu_links
public function nav_menu_links()
{
$exclude = array('view-order', 'add-payment-method', 'order-pay', 'order-received');
?>
<div id="posttype-woocommerce-endpoints" class="posttypediv">
<div id="tabs-panel-woocommerce-endpoints" class="tabs-panel tabs-panel-active">
<ul id="woocommerce-endpoints-checklist" class="categorychecklist form-no-clear">
<?php
$i = -1;
foreach (WC()->query->query_vars as $key => $value) {
if (in_array($key, $exclude)) {
continue;
}
?>
<li>
<label class="menu-item-title">
<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php
echo esc_attr($i);
?>
][menu-item-object-id]" value="<?php
echo esc_attr($i);
?>
" /> <?php
echo esc_html($key);
?>
</label>
<input type="hidden" class="menu-item-type" name="menu-item[<?php
echo esc_attr($i);
?>
][menu-item-type]" value="custom" />
<input type="hidden" class="menu-item-title" name="menu-item[<?php
echo esc_attr($i);
?>
][menu-item-title]" value="<?php
echo esc_html($key);
?>
" />
<input type="hidden" class="menu-item-url" name="menu-item[<?php
echo esc_attr($i);
?>
][menu-item-url]" value="<?php
echo esc_url(wc_get_endpoint_url($key, '', wc_get_page_permalink('myaccount')));
?>
" />
<input type="hidden" class="menu-item-classes" name="menu-item[<?php
echo esc_attr($i);
?>
][menu-item-classes]" />
</li>
<?php
$i--;
}
?>
</ul>
</div>
<p class="button-controls">
<span class="list-controls">
<a href="<?php
echo admin_url('nav-menus.php?page-tab=all&selectall=1#posttype-woocommerce-endpoints');
?>
" class="select-all"><?php
_e('Select All', 'woocommerce');
?>
</a>
</span>
<span class="add-to-menu">
<input type="submit" class="button-secondary submit-add-to-menu right" value="<?php
esc_attr_e('Add to Menu', 'woocommerce');
?>
" name="add-post-type-menu-item" id="submit-posttype-woocommerce-endpoints">
<span class="spinner"></span>
</span>
</p>
</div>
<?php
}
示例12: str_replace
$addr_key = str_replace('shipping_', '', $field_name);
$address[$addr_key] = isset($addr[$field_name]) ? $addr[$field_name] : '';
}
if (!empty($address)) {
$formatted_address = $woocommerce->countries->get_formatted_address($address);
$json_address = json_encode($address);
}
if (!$formatted_address) {
continue;
}
?>
<div class="account-address">
<?php
if (isset($addr['default_address']) && $addr['default_address']) {
if (function_exists('wc_get_endpoint_url')) {
echo '<a href="' . wc_get_endpoint_url('edit-address', 'shipping', get_permalink(woocommerce_get_page_id('myaccount'))) . '" class="edit">' . __('edit', 'wc_shipping_multiple_address') . '</a>';
} else {
echo '<a href="' . esc_url(add_query_arg('address', 'shipping', get_permalink(woocommerce_get_page_id('edit_address')))) . '" class="edit">' . __('edit', 'wc_shipping_multiple_address') . '</a>';
}
} else {
echo '<a class="edit" href="' . $addresses_url . '#shipping_address_' . $x . '">' . __('edit', 'wc_shipping_multiple_address') . '</a>';
}
?>
<address><?php
echo $formatted_address;
?>
</address>
<div style="display: none;">
<?php
示例13: wc_get_customer_orders
//.........这里部分代码省略.........
</td>
<?php
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
} else {
?>
<div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
<a class="woocommerce-Button button" href="<?php
echo esc_url(apply_filters('woocommerce_return_to_shop_redirect', wc_get_page_permalink('shop')));
?>
">
<?php
_e('Go Shop', 'woocommerce');
?>
</a>
<?php
_e('No order has been made yet.', 'woocommerce');
?>
</div>
<?php
}
?>
<?php
echo '<p><a href="' . esc_url(wc_get_endpoint_url('orders')) . '">Ver Todos</a></p>';
do_action('woocommerce_after_account_orders', $has_orders);
$customer_id = get_current_user_id();
if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) {
$get_addresses = apply_filters('woocommerce_my_account_get_addresses', array('billing' => __('Billing Address', 'woocommerce'), 'shipping' => __('Shipping Address', 'woocommerce')), $customer_id);
} else {
$get_addresses = apply_filters('woocommerce_my_account_get_addresses', array('billing' => __('Billing Address', 'woocommerce')), $customer_id);
}
$oldcol = 1;
$col = 1;
?>
<?php
if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) {
echo '<div class="u-columns woocommerce-Addresses col2-set addresses">';
}
?>
<?php
foreach ($get_addresses as $name => $title) {
?>
<div class="u-column<?php
echo ($col = $col * -1) < 0 ? 1 : 2;
?>
col-<?php
echo ($oldcol = $oldcol * -1) < 0 ? 1 : 2;
?>
woocommerce-Address">
<header class="woocommerce-Address-title title">
<h3>Cadastro</h3>
<a href="<?php
echo esc_url(wc_get_endpoint_url('edit-address', $name));
?>
" class="edit"><?php
_e('Edit', 'woocommerce');
?>
</a>
</header>
<address>
<?php
$address = apply_filters('woocommerce_my_account_my_address_formatted_address', array('first_name' => get_user_meta($customer_id, $name . '_first_name', true), 'last_name' => get_user_meta($customer_id, $name . '_last_name', true), 'company' => get_user_meta($customer_id, $name . '_company', true), 'address_1' => get_user_meta($customer_id, $name . '_address_1', true), 'address_2' => get_user_meta($customer_id, $name . '_address_2', true), 'city' => get_user_meta($customer_id, $name . '_city', true), 'state' => get_user_meta($customer_id, $name . '_state', true), 'postcode' => get_user_meta($customer_id, $name . '_postcode', true), 'country' => get_user_meta($customer_id, $name . '_country', true)), $customer_id, $name);
$formatted_address = WC()->countries->get_formatted_address($address);
if (!$formatted_address) {
_e('You have not set up this type of address yet.', 'woocommerce');
} else {
echo $formatted_address;
}
?>
</address>
</div>
<?php
}
?>
<?php
if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) {
echo '</div>';
}
?>
</div><!-- pedidos -->
<?php
}
示例14: apply_filters
?>
<h2><?php echo $page_title; ?></h2>
<p class="myaccount_address">
<?php echo apply_filters( 'woocommerce_my_account_my_address_description', __( 'The following addresses will be used on the checkout page by default.', 'woocommerce' ) ); ?>
</p>
<?php if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) echo '<div class="col2-set addresses">'; ?>
<?php foreach ( $get_addresses as $name => $title ) : ?>
<div class="col-<?php echo ( ( $col = $col * -1 ) < 0 ) ? 1 : 2; ?> address">
<header class="title">
<h3 ><?php echo $title; ?></h3>
<a href="<?php echo wc_get_endpoint_url( 'edit-address', $name ); ?>/#myaccount" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
</header>
<address>
<?php
$address = apply_filters( 'woocommerce_my_account_my_address_formatted_address', array(
'first_name' => get_user_meta( $customer_id, $name . '_first_name', true ),
'last_name' => get_user_meta( $customer_id, $name . '_last_name', true ),
'company' => get_user_meta( $customer_id, $name . '_company', true ),
'address_1' => get_user_meta( $customer_id, $name . '_address_1', true ),
'address_2' => get_user_meta( $customer_id, $name . '_address_2', true ),
'city' => get_user_meta( $customer_id, $name . '_city', true ),
'state' => get_user_meta( $customer_id, $name . '_state', true ),
'postcode' => get_user_meta( $customer_id, $name . '_postcode', true ),
'country' => get_user_meta( $customer_id, $name . '_country', true )
), $customer_id, $name );
示例15: echo
?>
<div class="u-column<?php
echo ($col = $col * -1) < 0 ? 1 : 2;
?>
col-<?php
echo ($oldcol = $oldcol * -1) < 0 ? 1 : 2;
?>
woocommerce-Address">
<header class="woocommerce-Address-title title">
<h3><?php
echo $title;
?>
</h3>
<a href="<?php
echo esc_url(wc_get_endpoint_url('edit-address', $name));
?>
" class="edit"><?php
_e('Edit', 'woocommerce');
?>
</a>
</header>
<address>
<?php
$address = apply_filters('woocommerce_my_account_my_address_formatted_address', array('first_name' => get_user_meta($customer_id, $name . '_first_name', true), 'last_name' => get_user_meta($customer_id, $name . '_last_name', true), 'company' => get_user_meta($customer_id, $name . '_company', true), 'address_1' => get_user_meta($customer_id, $name . '_address_1', true), 'address_2' => get_user_meta($customer_id, $name . '_address_2', true), 'city' => get_user_meta($customer_id, $name . '_city', true), 'state' => get_user_meta($customer_id, $name . '_state', true), 'postcode' => get_user_meta($customer_id, $name . '_postcode', true), 'country' => get_user_meta($customer_id, $name . '_country', true)), $customer_id, $name);
$formatted_address = WC()->countries->get_formatted_address($address);
if (!$formatted_address) {
_e('You have not set up this type of address yet.', 'woocommerce');
} else {
echo $formatted_address;
}