Esempio n. 1
0
function get_order_email_arguments($order_id)
{
    $options = Jigoshop_Base::get_options();
    $order = new jigoshop_order($order_id);
    $inc_tax = $options->get('jigoshop_calc_taxes') == 'no' || $options->get('jigoshop_prices_include_tax') == 'yes';
    $can_show_links = $order->status == 'completed' || $order->status == 'processing';
    $statuses = $order->get_order_statuses_and_names();
    $variables = array('blog_name' => get_bloginfo('name'), 'order_number' => $order->get_order_number(), 'order_date' => date_i18n(get_option('date_format')), 'order_status' => $statuses[$order->status], 'shop_name' => $options->get('jigoshop_company_name'), 'shop_address_1' => $options->get('jigoshop_address_1'), 'shop_address_2' => $options->get('jigoshop_address_2'), 'shop_tax_number' => $options->get('jigoshop_tax_number'), 'shop_phone' => $options->get('jigoshop_company_phone'), 'shop_email' => $options->get('jigoshop_company_email'), 'customer_note' => $order->customer_note, 'order_items_table' => jigoshop_get_order_items_table($order, $can_show_links, true, $inc_tax), 'order_items' => $order->email_order_items_list($can_show_links, true, $inc_tax), 'order_taxes' => jigoshop_get_order_taxes_list($order), 'subtotal' => $order->get_subtotal_to_display(), 'shipping' => $order->get_shipping_to_display(), 'shipping_cost' => jigoshop_price($order->order_shipping), 'shipping_method' => $order->shipping_service, 'discount' => jigoshop_price($order->order_discount), 'applied_coupons' => jigoshop_get_order_coupon_list($order), 'total_tax' => jigoshop_price($order->get_total_tax()), 'total' => jigoshop_price($order->order_total), 'is_local_pickup' => $order->shipping_method == 'local_pickup' ? true : null, 'checkout_url' => $order->status == 'pending' ? $order->get_checkout_payment_url() : null, 'payment_method' => $order->payment_method_title, 'is_bank_transfer' => $order->payment_method == 'bank_transfer' ? true : null, 'is_cash_on_delivery' => $order->payment_method == 'cod' ? true : null, 'is_cheque' => $order->payment_method == 'cheque' ? true : null, 'bank_info' => str_replace(PHP_EOL, '', jigoshop_bank_transfer::get_bank_details()), 'cheque_info' => str_replace(PHP_EOL, '', $options->get('jigoshop_cheque_description')), 'billing_first_name' => $order->billing_first_name, 'billing_last_name' => $order->billing_last_name, 'billing_company' => $order->billing_company, 'billing_euvatno' => $order->billing_euvatno, 'billing_address_1' => $order->billing_address_1, 'billing_address_2' => $order->billing_address_2, 'billing_postcode' => $order->billing_postcode, 'billing_city' => $order->billing_city, 'billing_country' => jigoshop_countries::get_country($order->billing_country), 'billing_state' => strlen($order->billing_state) == 2 ? jigoshop_countries::get_state($order->billing_country, $order->billing_state) : $order->billing_state, 'billing_country_raw' => $order->billing_country, 'billing state_raw' => $order->billing_state, 'billing_email' => $order->billing_email, 'billing_phone' => $order->billing_phone, 'shipping_first_name' => $order->shipping_first_name, 'shipping_last_name' => $order->shipping_last_name, 'shipping_company' => $order->shipping_company, 'shipping_address_1' => $order->shipping_address_1, 'shipping_address_2' => $order->shipping_address_2, 'shipping_postcode' => $order->shipping_postcode, 'shipping_city' => $order->shipping_city, 'shipping_country' => jigoshop_countries::get_country($order->shipping_country), 'shipping_state' => strlen($order->shipping_state) == 2 ? jigoshop_countries::get_state($order->shipping_country, $order->shipping_state) : $order->shipping_state, 'shipping_country_raw' => $order->shipping_country, 'shipping_state_raw' => $order->shipping_state);
    if ($options->get('jigoshop_calc_taxes') == 'yes') {
        $variables['all_tax_classes'] = $variables['order_taxes'];
    } else {
        unset($variables['order_taxes']);
    }
    return apply_filters('jigoshop_order_email_variables', $variables, $order_id);
}
 /** Gets the country and state from the current session for cart shipping display */
 public static function get_shipping_country_or_state()
 {
     $country = self::get_customer_session('shipping_country');
     if ($country) {
         $state = trim(self::get_customer_session('shipping_state'), ':');
         if ($state && jigoshop_countries::country_has_states($country)) {
             return jigoshop_countries::get_state($country, $state);
         } else {
             return jigoshop_countries::get_country($country);
         }
     }
     $country = jigoshop_countries::get_default_customer_country();
     return jigoshop_countries::get_country($country);
 }
Esempio n. 3
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. 4
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. 5
0
 public static function get_tax_for_display($tax_class)
 {
     $return = false;
     if (jigoshop_cart::get_tax_amount($tax_class, false) > 0 && jigoshop_cart::get_tax_rate($tax_class) > 0 || jigoshop_cart::get_tax_rate($tax_class) !== false) {
         $return = self::$tax->get_tax_class_for_display($tax_class) . ' (' . (double) jigoshop_cart::get_tax_rate($tax_class) . '%) ';
         // only show estimated tag when customer is on the cart page and no shipping calculator is enabled to be able to change country
         if (!jigoshop_shipping::show_shipping_calculator() && is_cart()) {
             $return .= '<small>' . sprintf(__('estimated for: %s', 'jigoshop'), jigoshop_countries::get_country(jigoshop_tax::get_customer_country())) . '</small>';
         }
     }
     return $return;
 }
Esempio n. 6
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;
     }
 }
Esempio n. 7
0
 /**
  *  Admin Notices for conditions under which FuturePay is available on a Shop
  */
 public function futurepay_notices()
 {
     if ($this->enabled == 'no') {
         return;
     }
     if (!in_array(Jigoshop_Base::get_options()->get('jigoshop_currency'), $this->allowed_currency)) {
         echo '<div class="error"><p>' . sprintf(__('The FuturePay gateway accepts payments in currencies of %s.  Your current currency is %s.  FuturePay won\'t work until you change the Jigoshop currency to an accepted one.  FuturePay is currently disabled on the Payment Gateways settings tab.', 'jigoshop'), implode(', ', $this->allowed_currency), Jigoshop_Base::get_options()->get('jigoshop_currency')) . '</p></div>';
         Jigoshop_Base::get_options()->set('jigoshop_futurepay_enabled', 'no');
     }
     if (!in_array($this->shop_base_country, $this->merchant_countries)) {
         $country_list = array();
         foreach ($this->merchant_countries as $this_country) {
             $country_list[] = jigoshop_countries::get_country($this_country);
         }
         echo '<div class="error"><p>' . sprintf(__('The FuturePay gateway is available to merchants from: %s.  Your country is: %s.  FuturePay won\'t work until you change the Jigoshop Shop Base country to an accepted one.  FuturePay is currently disabled on the Payment Gateways settings tab.', 'jigoshop'), implode(', ', $country_list), jigoshop_countries::get_base_country()) . '</p></div>';
         Jigoshop_Base::get_options()->set('jigoshop_futurepay_enabled', 'no');
     }
 }