/** * 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; }
/** * @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(); } }
/** * 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); }
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; } }
/** * 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; } }
/** * 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); }
* @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)); ?>
<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 {
/** * @deprecated */ function woocommerce_get_endpoint_url($endpoint, $value = '', $permalink = '') { return wc_get_endpoint_url($endpoint, $value, $permalink); }
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 }
$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
function wc_get_customer_orders() { // Get all customer orders $customer_orders = get_posts(array('numberposts' => 4, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => wc_get_order_types(), 'post_status' => array_keys(wc_get_order_statuses()))); if ($customer_orders > 0) { $has_orders = 1; } else { $has_orders = 0; } do_action('woocommerce_before_account_orders', $has_orders); ?> <div class="pedidos"> <?php if ($has_orders) { ?> <h4>Pedidos Recentes</h4> <table class="woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table"> <thead> <tr> <?php foreach (wc_get_account_orders_columns() as $column_id => $column_name) { ?> <th class="<?php echo esc_attr($column_id); ?> "><span class="nobr"><?php echo esc_html($column_name); ?> </span></th> <?php } ?> </tr> </thead> <tbody> <?php foreach ($customer_orders as $customer_order) { $order = wc_get_order($customer_order); $item_count = $order->get_item_count(); ?> <tr class="order"> <?php foreach (wc_get_account_orders_columns() as $column_id => $column_name) { ?> <td class="<?php echo esc_attr($column_id); ?> " data-title="<?php echo esc_attr($column_name); ?> "> <?php if (has_action('woocommerce_my_account_my_orders_column_' . $column_id)) { ?> <?php do_action('woocommerce_my_account_my_orders_column_' . $column_id, $order); ?> <?php } elseif ('order-number' === $column_id) { ?> <a href="<?php echo esc_url($order->get_view_order_url()); ?> "> <?php echo _x('#', 'hash before order number', 'woocommerce') . $order->get_order_number(); ?> </a> <?php } elseif ('order-date' === $column_id) { ?> <time datetime="<?php echo date('Y-m-d', strtotime($order->order_date)); ?> " title="<?php echo esc_attr(strtotime($order->order_date)); ?> "><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?> </time> <?php } elseif ('order-status' === $column_id) { ?> <?php echo wc_get_order_status_name($order->get_status()); ?> <?php } elseif ('order-total' === $column_id) { ?> <?php echo sprintf(_n('%s for %s item', '%s for %s items', $item_count, 'woocommerce'), $order->get_formatted_order_total(), $item_count); ?> <?php } elseif ('order-actions' === $column_id) { ?> <?php $actions = array('pay' => array('url' => $order->get_checkout_payment_url(), 'name' => __('Pay', 'woocommerce')), 'view' => array('url' => $order->get_view_order_url(), 'name' => __('View', 'woocommerce')), 'cancel' => array('url' => $order->get_cancel_order_url(wc_get_page_permalink('myaccount')), 'name' => __('Cancel', 'woocommerce'))); if (!$order->needs_payment()) { unset($actions['pay']); } if (!in_array($order->get_status(), apply_filters('woocommerce_valid_order_statuses_for_cancel', array('pending', 'failed'), $order))) { unset($actions['cancel']); } if ($actions = apply_filters('woocommerce_my_account_my_orders_actions', $actions, $order)) { foreach ($actions as $key => $action) { echo '<a href="' . esc_url($action['url']) . '" class="button ' . sanitize_html_class($key) . '">' . esc_html($action['name']) . '</a>'; } } ?> <?php } ?> </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 }
?> <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 );
?> <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; }
<?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); ?> " 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; }
/** * Entry method for the Add Payment Method feature flow. Note this is *not* * stubbed in the WC_Payment_Gateway abstract class, but is called if the * gateway declares support for it. * * @since 4.0.0 */ public function add_payment_method() { assert($this->supports_add_payment_method()); $order = $this->get_order_for_add_payment_method(); try { $result = $this->do_add_payment_method_transaction($order); } catch (SV_WC_Plugin_Exception $e) { $result = array('message' => sprintf(esc_html__('Oops, adding your new payment method failed: %s', 'woocommerce-plugin-framework'), $e->getMessage()), 'success' => false); } SV_WC_Helper::wc_add_notice($result['message'], $result['success'] ? 'success' : 'error'); // if successful, redirect to the newly added method if ($result['success']) { // if this is WooCommerce 2.5.5 or older, redirect to the My Account page if (SV_WC_Plugin_Compatibility::is_wc_version_lt_2_6()) { $redirect_url = wc_get_page_permalink('myaccount'); // otherwise, redirect to the Payment Methods page (WC 2.6+) } else { $redirect_url = wc_get_account_endpoint_url('payment-methods'); } // otherwise, back to the Add Payment Method page } else { $redirect_url = wc_get_endpoint_url('add-payment-method'); } wp_safe_redirect($redirect_url); exit; }
/** * Return the table title HTML, text defaults to "My Payment Methods" * * @since 4.0.0 * @return string table title HTML */ protected function get_table_title_html() { $title = apply_filters('wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_title', __('My Payment Methods', $this->get_plugin()->get_text_domain()), $this); $html = '<div class="sv-wc-payment-gateway-my-payment-methods-table-title">'; $html .= sprintf('<h2 id="wc-%s-my-payment-methods">%s</h2>', $this->get_plugin()->get_id_dasherized(), esc_html($title)); if ($this->supports_add_payment_method()) { $html .= sprintf('<a class="button sv-wc-payment-gateway-my-payment-methods-add-payment-method-button dashicons-before dashicons-plus-alt" href="%s">%s</a>', esc_url(wc_get_endpoint_url('add-payment-method')), esc_html_x('Add New Payment Method', 'Supports add new payment method feature', $this->get_plugin()->get_text_domain())); } $html .= '</div>'; return apply_filters('wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_title_html', $html, $this); }
*/ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } ?> <p> <?php echo sprintf(esc_attr__('Hello %s%s%s (not %2$s? %sSign out%s)', 'woocommerce'), '<strong>', esc_html($current_user->display_name), '</strong>', '<a href="' . esc_url(wc_logout_url(wc_get_page_permalink('myaccount'))) . '">', '</a>'); ?> </p> <p> <?php echo sprintf(esc_attr__('From your account dashboard you can view your %1$srecent orders%2$s, manage your %3$sshipping and billing addresses%2$s and %4$sedit your password and account details%2$s.', 'woocommerce'), '<a href="' . esc_url(wc_get_endpoint_url('orders')) . '">', '</a>', '<a href="' . esc_url(wc_get_endpoint_url('edit-address')) . '">', '<a href="' . esc_url(wc_get_endpoint_url('edit-account')) . '">'); ?> </p> <?php /** * My Account dashboard. * * @since 2.6.0 */ do_action('woocommerce_account_dashboard'); /** * Deprecated woocommerce_before_my_account action. * * @deprecated 2.6.0 */
/** * User top navigation menu * * @return void */ function dokan_header_user_menu() { ?> <ul class="nav navbar-nav navbar-right"> <li> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php printf(__('Cart %s', 'dokan'), '<span class="dokan-cart-amount-top">(' . WC()->cart->get_cart_total() . ')</span>'); ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <li> <div class="widget_shopping_cart_content"></div> </li> </ul> </li> <?php if (is_user_logged_in()) { ?> <?php global $current_user; $user_id = $current_user->ID; if (dokan_is_user_seller($user_id)) { ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php _e('Seller Dashboard', 'dokan'); ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="<?php echo dokan_get_store_url($user_id); ?> " target="_blank"><?php _e('Visit your store', 'dokan'); ?> <i class="fa fa-external-link"></i></a></li> <li class="divider"></li> <?php $nav_urls = dokan_get_dashboard_nav(); foreach ($nav_urls as $key => $item) { printf('<li><a href="%s">%s %s</a></li>', $item['url'], $item['icon'], $item['title']); } ?> </ul> </li> <?php } ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo esc_html($current_user->display_name); ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="<?php echo dokan_get_page_url('my_orders'); ?> "><?php _e('My Orders', 'dokan'); ?> </a></li> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('My Account', 'dokan'); ?> </a></li> <li><a href="<?php echo wc_customer_edit_account_url(); ?> "><?php _e('Edit Account', 'dokan'); ?> </a></li> <li class="divider"></li> <li><a href="<?php echo wc_get_endpoint_url('edit-address', 'billing', get_permalink(wc_get_page_id('myaccount'))); ?> "><?php _e('Billing Address', 'dokan'); ?> </a></li> <li><a href="<?php echo wc_get_endpoint_url('edit-address', 'shipping', get_permalink(wc_get_page_id('myaccount'))); ?> "><?php _e('Shipping Address', 'dokan'); ?> </a></li> </ul> </li> <li><?php wp_loginout(home_url()); ?> </li> <?php } else { ?> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('Log in', 'dokan'); ?> </a></li> <li><a href="<?php echo dokan_get_page_url('myaccount', 'woocommerce'); ?> "><?php _e('Sign Up', 'dokan'); ?> </a></li> <?php } ?> </ul> <?php }
/** * Build auth urls * * @since 2.4.0 * * @param array $data * @param string $endpoint * * @return string */ protected function build_url($data, $endpoint) { $url = wc_get_endpoint_url('wc-auth/v' . self::VERSION, $endpoint, home_url('/')); return add_query_arg(array('app_name' => wc_clean($data['app_name']), 'user_id' => wc_clean($data['user_id']), 'return_url' => urlencode($data['return_url']), 'callback_url' => urlencode($data['callback_url']), 'scope' => wc_clean($data['scope'])), $url); }
/** * Entry method for the Add Payment Method feature flow. Note this is *not* * stubbed in the WC_Payment_Gateway abstract class, but is called if the * gateway declares support for it. * * @since 4.0.0 */ public function add_payment_method() { assert($this->supports_add_payment_method()); $order = $this->get_order_for_add_payment_method(); try { $result = $this->do_add_payment_method_transaction($order); } catch (SV_WC_Plugin_Exception $e) { $result = array('message' => sprintf(__('Oops, adding your new payment method failed: %s', $this->text_domain), $e->getMessage()), 'success' => false); } SV_WC_Helper::wc_add_notice($result['message'], $result['success'] ? 'success' : 'error'); // redirect to my account on success, or back to Add Payment Method screen on failure so user can try again wp_safe_redirect($result['success'] ? SV_WC_Plugin_Compatibility::wc_get_page_permalink('myaccount') : wc_get_endpoint_url('add-payment-method')); exit; }
function get_edit_billing_address_url() { $account_edit_adress_url = wc_get_endpoint_url('edit-address', '', get_permalink(wc_get_page_id('myaccount'))); $edit_billing_address_url = $account_edit_adress_url . "billing/"; return $edit_billing_address_url; }
} ?> </table> <?php } else { ?> <p><?php esc_html_e('No saved method found.', 'woocommerce'); ?> </p> <?php } ?> <?php do_action('woocommerce_after_account_payment_methods', $has_methods); ?> <a class="button" href="<?php echo esc_url(wc_get_endpoint_url('add-payment-method')); ?> "><?php esc_html_e('Add New Payment Method', 'woocommerce'); ?> </a> </div>
/** * Returns an array of a user's saved payments list for output on the account tab. * * @since 2.6 * @param array $list List of payment methods passed from wc_get_customer_saved_methods_list() * @param int $customer_id The customer to fetch payment methods for * @return array Filtered list of customers payment methods */ function wc_get_account_saved_payment_methods_list($list, $customer_id) { $payment_tokens = WC_Payment_Tokens::get_customer_tokens($customer_id); foreach ($payment_tokens as $payment_token) { $delete_url = wc_get_endpoint_url('delete-payment-method', $payment_token->get_id()); $delete_url = wp_nonce_url($delete_url, 'delete-payment-method-' . $payment_token->get_id()); $set_default_url = wc_get_endpoint_url('set-default-payment-method', $payment_token->get_id()); $set_default_url = wp_nonce_url($set_default_url, 'set-default-payment-method-' . $payment_token->get_id()); $type = strtolower($payment_token->get_type()); $list[$type][] = array('method' => array('gateway' => $payment_token->get_gateway_id()), 'expires' => esc_html__('N/A', 'woocommerce'), 'is_default' => $payment_token->is_default(), 'actions' => array('delete' => array('url' => $delete_url, 'name' => esc_html__('Delete', 'woocommerce')))); $key = key(array_slice($list[$type], -1, 1, true)); if (!$payment_token->is_default()) { $list[$type][$key]['actions']['default'] = array('url' => $set_default_url, 'name' => esc_html__('Make Default', 'woocommerce')); } $list[$type][$key] = apply_filters('woocommerce_payment_methods_list_item', $list[$type][$key], $payment_token); } return $list; }
public function add_payment_method() { if (empty($_POST['simplify_token'])) { wc_add_notice(__('There was a problem adding this card.', 'woocommerce'), 'error'); return; } $cart_token = wc_clean($_POST['simplify_token']); $customer_token = $this->get_users_token(); $current_user = wp_get_current_user(); $customer_info = array('email' => $current_user->user_email, 'name' => $current_user->display_name); $token = $this->save_token($customer_token, $cart_token, $customer_info); if (is_null($token)) { wc_add_notice(__('There was a problem adding this card.', 'woocommerce'), 'error'); return; } return array('result' => 'success', 'redirect' => wc_get_endpoint_url('payment-methods')); }
<section id="order__intro__section"> <!-- Home header subtitle --> <h2 class="page__subtitle">Your Account Page</h2> <!-- Home header title --> <h1 class="page__title"> <?php printf(__('Hello %1$s', 'woocommerce') . ' ', $current_user->display_name); ?> </h1> <div class="steps__frame"> <p> <?php printf(__('Are you not %1$s? <a href="%2$s">Sign out</a>.', 'woocommerce') . ' ', $current_user->display_name, wc_get_endpoint_url('customer-logout', '', wc_get_page_permalink('myaccount'))); ?> <br> <?php printf(__('Here you can view your recent orders and <a href="%s">edit your password and account details</a>.', 'woocommerce'), wc_customer_edit_account_url()); ?> </p> </div> <div class="home__intro__section__mascotte"> </div> </section> </div>
function filter_get_endpoint_url($url, $endpoint, $value, $permalink) { // return translated edit account slugs if (isset(WC()->query->query_vars['edit-address']) && isset(WC()->query->query_vars['edit-address']) == $endpoint && in_array($value, array('shipping', 'billing'))) { remove_filter('woocommerce_get_endpoint_url', array($this, 'filter_get_endpoint_url'), 10, 4); $url = wc_get_endpoint_url('edit-address', $this->get_translated_edit_address_slug($value)); add_filter('woocommerce_get_endpoint_url', array($this, 'filter_get_endpoint_url'), 10, 4); } return $url; }
/** * @param $gateway_id * @param $order_id * @param $response * @return string */ private function payment_redirect($gateway_id, $order_id, $response) { $message = $response['messages']; // compare url fragments $success_url = wc_get_endpoint_url('order-received', $order_id, get_permalink(wc_get_page_id('checkout'))); $success = wp_parse_args(parse_url($success_url), array('host' => '', 'path' => '')); $redirect = wp_parse_args(parse_url($response['redirect']), array('host' => '', 'path' => '')); $offsite = $success['host'] !== $redirect['host']; $reload = !$offsite && $success['path'] !== $redirect['path'] && $response['messages'] == ''; if ($offsite || $reload) { update_post_meta($order_id, '_pos_payment_redirect', $response['redirect']); $message = __('You are now being redirected offsite to complete the payment. ', 'woocommerce-pos'); $message .= sprintf(__('<a href="%s">Click here</a> if you are not redirected automatically. ', 'woocommerce-pos'), $response['redirect']); } return $message; }
/** * Generates a URL to view an order from the my account page * * @return string */ public function get_view_order_url() { $view_order_url = wc_get_endpoint_url('view-order', $this->id, wc_get_page_permalink('myaccount')); return apply_filters('woocommerce_get_view_order_url', $view_order_url, $this); }
/** * 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; }