Esempio n. 1
0
			<h3><?php 
    _e('Shipping Address', 'jigoshop');
    ?>
</h3>
			<a href="<?php 
    echo esc_url(add_query_arg('address', 'shipping', apply_filters('jigoshop_get_edit_address_page_id', get_permalink(jigoshop_get_page_id('edit_address')))));
    ?>
" class="edit"><?php 
    _e('Edit', 'jigoshop');
    ?>
</a>
		</header>
		<address>
			<?php 
    $country = get_user_meta(get_current_user_id(), 'shipping_country', true);
    $country = jigoshop_countries::has_country($country) ? jigoshop_countries::get_country($country) : '';
    $address = array(get_user_meta(get_current_user_id(), 'shipping_first_name', true) . ' ' . get_user_meta(get_current_user_id(), 'shipping_last_name', true), get_user_meta(get_current_user_id(), 'shipping_company', true), get_user_meta(get_current_user_id(), 'shipping_address_1', true), get_user_meta(get_current_user_id(), 'shipping_address_2', true), get_user_meta(get_current_user_id(), 'shipping_city', true), get_user_meta(get_current_user_id(), 'shipping_state', true), get_user_meta(get_current_user_id(), 'shipping_postcode', true), $country);
    $address = array_map('trim', $address);
    $formatted_address = implode(', ', array_filter($address));
    if (!$formatted_address) {
        _e('You have not set up a shipping address yet.', 'jigoshop');
    } else {
        echo $formatted_address;
    }
    ?>
		</address>
	</div>
</div>
<?php 
    do_action('jigoshop_after_my_account');
} else {
Esempio n. 2
0
 public function __construct($id)
 {
     $this->id = $id;
     $meta = get_user_meta($id);
     if (isset($meta['billing_first_name'])) {
         $this->billing_first_name = $meta['billing_first_name'][0];
     }
     if (isset($meta['billing_last_name'])) {
         $this->billing_last_name = $meta['billing_last_name'][0];
     }
     if (isset($meta['billing_company'])) {
         $this->billing_company = $meta['billing_company'][0];
     }
     if (isset($meta['billing_euvatno'])) {
         $this->billing_euvatno = $meta['billing_euvatno'][0];
     }
     if (isset($meta['billing_address_1'])) {
         $this->billing_address_1 = $meta['billing_address_1'][0];
     }
     if (isset($meta['billing_address_2'])) {
         $this->billing_address_2 = $meta['billing_address_2'][0];
     }
     if (isset($meta['billing_city'])) {
         $this->billing_city = $meta['billing_city'][0];
     }
     if (isset($meta['billing_state'])) {
         $this->billing_state = $meta['billing_state'][0];
     }
     if (isset($meta['billing_postcode'])) {
         $this->billing_postcode = $meta['billing_postcode'][0];
     }
     if (isset($meta['billing_country'])) {
         $country = $meta['billing_country'][0];
         $country = jigoshop_countries::has_country($country) ? $country : jigoshop_countries::get_base_country();
         $this->billing_country = $country;
     }
     if (isset($meta['billing_email'])) {
         $this->billing_email = $meta['billing_email'][0];
     }
     if (isset($meta['billing_first_name'])) {
         $this->billing_phone = $meta['billing_phone'][0];
     }
     if (isset($meta['shipping_first_name'])) {
         $this->shipping_first_name = $meta['shipping_first_name'][0];
     }
     if (isset($meta['shipping_last_name'])) {
         $this->shipping_last_name = $meta['shipping_last_name'][0];
     }
     if (isset($meta['shipping_company'])) {
         $this->shipping_company = $meta['shipping_company'][0];
     }
     if (isset($meta['shipping_address_1'])) {
         $this->shipping_address_1 = $meta['shipping_address_1'][0];
     }
     if (isset($meta['shipping_address_2'])) {
         $this->shipping_address_2 = $meta['shipping_address_2'][0];
     }
     if (isset($meta['shipping_city'])) {
         $this->shipping_city = $meta['shipping_city'][0];
     }
     if (isset($meta['shipping_state'])) {
         $this->shipping_state = $meta['shipping_state'][0];
     }
     if (isset($meta['shipping_postcode'])) {
         $this->shipping_postcode = $meta['shipping_postcode'][0];
     }
     if (isset($meta['shipping_country'])) {
         $country = $meta['shipping_country'][0];
         $country = jigoshop_countries::has_country($country) ? $country : jigoshop_countries::get_base_country();
         $this->shipping_country = $country;
     }
 }
Esempio n. 3
0
    function column_default($user, $column_name)
    {
        switch ($column_name) {
            case 'customer_name':
                if ($user->last_name && $user->first_name) {
                    return $user->last_name . ', ' . $user->first_name;
                } else {
                    return '-';
                }
            case 'username':
                return $user->user_login;
            case 'location':
                $state_code = get_user_meta($user->ID, 'billing_state', true);
                $country_code = get_user_meta($user->ID, 'billing_country', true);
                $state = jigoshop_countries::has_state($country_code, $state_code) ? jigoshop_countries::get_state($country_code, $state_code) : $state_code;
                $country = jigoshop_countries::has_country($country_code) ? jigoshop_countries::get_country($country_code) : $country_code;
                $value = '';
                if ($state) {
                    $value .= $state . ', ';
                }
                $value .= $country;
                if ($value) {
                    return $value;
                } else {
                    return '-';
                }
            case 'email':
                return '<a href="mailto:' . $user->user_email . '">' . $user->user_email . '</a>';
            case 'spent':
                return jigoshop_price(jigoshop_get_customer_total_spent($user->ID));
            case 'orders':
                return jigoshop_get_customer_order_count($user->ID);
            case 'last_order':
                $order_ids = get_posts(array('posts_per_page' => 1, 'post_type' => 'shop_order', 'post_status' => array('publish'), 'orderby' => 'date', 'order' => 'desc', 'meta_query' => array(array('key' => 'customer_user', 'value' => $user->ID)), 'fields' => 'ids'));
                if ($order_ids) {
                    $order = new jigoshop_order($order_ids[0]);
                    return '<a href="' . admin_url('post.php?post=' . $order->id . '&action=edit') . '">' . $order->get_order_number() . '</a> &ndash; ' . date_i18n(get_option('date_format'), strtotime($order->order_date));
                } else {
                    return '-';
                }
                break;
            case 'user_actions':
                ob_start();
                ?>
<p>
				<?php 
                do_action('jigoshop_admin_user_actions_start', $user);
                $actions = array();
                $actions['refresh'] = array('url' => wp_nonce_url(add_query_arg('refresh', $user->ID), 'refresh'), 'name' => __('Refresh stats', 'jigoshop'), 'action' => 'refresh');
                $actions['edit'] = array('url' => admin_url('user-edit.php?user_id=' . $user->ID), 'name' => __('Edit', 'jigoshop'), 'action' => 'edit');
                $order_ids = $this->get_guest_orders();
                $order_ids = array_map(function ($order) {
                    return $order->ID;
                }, array_filter($order_ids, function ($order) use($user) {
                    return $order->data['billing_email'] == $user->user_email;
                }));
                if ($order_ids) {
                    $actions['link'] = array('url' => wp_nonce_url(add_query_arg('link_orders', $user->ID), 'link_orders'), 'name' => __('Link previous orders', 'jigoshop'), 'action' => 'link');
                }
                $actions = apply_filters('jigoshop_admin_user_actions', $actions, $user);
                foreach ($actions as $action) {
                    printf('<a class="button tips %s" href="%s" data-tip="%s">%s</a>', esc_attr($action['action']), esc_url($action['url']), esc_attr($action['name']), esc_attr($action['name']));
                }
                do_action('jigoshop_admin_user_actions_end', $user);
                ?>
				</p><?php 
                $user_actions = ob_get_contents();
                ob_end_clean();
                return $user_actions;
        }
        return '';
    }
Esempio n. 4
0
 /** Populates an order from the loaded post data */
 public function populate($result)
 {
     // Standard post data
     $this->id = $result->ID;
     $this->order_date = $result->post_date;
     $this->modified_date = $result->post_modified;
     $this->customer_note = $result->post_excerpt;
     // Custom field data
     $this->order_key = (string) get_post_meta($this->id, 'order_key', true);
     $this->user_id = (int) get_post_meta($this->id, 'customer_user', true);
     $this->items = (array) get_post_meta($this->id, 'order_items', true);
     $this->order_data = (array) maybe_unserialize(get_post_meta($this->id, 'order_data', true));
     $this->billing_first_name = (string) $this->_fetch('billing_first_name');
     $this->billing_last_name = (string) $this->_fetch('billing_last_name');
     $this->billing_company = (string) $this->_fetch('billing_company');
     $this->billing_euvatno = (string) $this->_fetch('billing_euvatno');
     $this->billing_address_1 = (string) $this->_fetch(array('billing_address_1', 'billing_address'));
     $this->billing_address_2 = (string) $this->_fetch('billing_address_2');
     $this->billing_city = (string) $this->_fetch('billing_city');
     $this->billing_postcode = (string) $this->_fetch('billing_postcode');
     $this->billing_country = (string) $this->_fetch('billing_country');
     $this->billing_state = (string) $this->_fetch('billing_state');
     $this->billing_email = (string) $this->_fetch('billing_email');
     $this->billing_phone = (string) $this->_fetch('billing_phone');
     $this->shipping_first_name = (string) $this->_fetch('shipping_first_name');
     $this->shipping_last_name = (string) $this->_fetch('shipping_last_name');
     $this->shipping_company = (string) $this->_fetch('shipping_company');
     $this->shipping_address_1 = (string) $this->_fetch(array('shipping_address_1', 'shipping_address'));
     $this->shipping_address_2 = (string) $this->_fetch('shipping_address_2');
     $this->shipping_city = (string) $this->_fetch('shipping_city');
     $this->shipping_postcode = (string) $this->_fetch('shipping_postcode');
     $this->shipping_country = (string) $this->_fetch('shipping_country');
     $this->shipping_state = (string) $this->_fetch('shipping_state');
     $this->shipping_method = (string) $this->_fetch('shipping_method');
     $this->shipping_service = (string) $this->_fetch('shipping_service');
     $this->payment_method = (string) $this->_fetch('payment_method');
     $this->payment_method_title = (string) $this->_fetch('payment_method_title');
     $this->order_subtotal = (string) $this->_fetch('order_subtotal');
     $this->order_discount_subtotal = (string) $this->_fetch('order_discount_subtotal');
     $this->order_shipping = (string) $this->_fetch('order_shipping');
     $this->order_discount = (string) $this->_fetch('order_discount');
     $this->order_discount_coupons = $this->_fetch('order_discount_coupons');
     //array
     $this->order_tax = $this->get_order_tax_array('order_tax');
     $this->order_shipping_tax = (string) $this->_fetch('order_shipping_tax');
     $this->order_total = (string) $this->_fetch('order_total');
     // array
     $this->order_total_prices_per_tax_class_ex_tax = $this->_fetch('order_total_prices_per_tax_class_ex_tax');
     // Formatted Addresses
     $country = $this->billing_country && jigoshop_countries::has_country($this->billing_country) ? jigoshop_countries::get_country($this->billing_country) : $this->billing_country;
     $address = array_map('trim', array($this->billing_address_1, $this->billing_address_2, $this->billing_city, $this->billing_state, $country, $this->billing_postcode));
     $this->formatted_billing_address = implode(', ', array_filter($address));
     if ($this->shipping_address_1) {
         $country = $this->shipping_country && jigoshop_countries::has_country($this->shipping_country) ? jigoshop_countries::get_country($this->shipping_country) : $this->shipping_country;
         $address = array_map('trim', array($this->shipping_address_1, $this->shipping_address_2, $this->shipping_city, $this->shipping_state, $country, $this->shipping_postcode));
         $this->formatted_shipping_address = implode(', ', array_filter($address));
     }
     // Taxonomy data
     $this->status = 'new';
     $terms = get_the_terms($this->id, 'shop_order_status');
     if (!is_wp_error($terms) && $terms) {
         $term = current($terms);
         $this->status = $term->slug;
     }
 }