示例#1
0
/**
 * Outputs the thankyou page
 **/
function jigoshop_thankyou()
{
    $thankyou_message = __('<p>Thank you. Your order has been processed successfully.</p>', 'jigoshop');
    echo apply_filters('jigoshop_thankyou_message', $thankyou_message);
    // Pay for order after checkout step
    if (isset($_GET['order'])) {
        $order_id = $_GET['order'];
    } else {
        $order_id = 0;
    }
    if (isset($_GET['key'])) {
        $order_key = $_GET['key'];
    } else {
        $order_key = '';
    }
    if ($order_id > 0) {
        $order = new jigoshop_order($order_id);
        if ($order->order_key == $order_key) {
            ?>
			<?php 
            do_action('jigoshop_thankyou_before_order_details', $order->id);
            ?>
			<ul class="order_details">
				<li class="order">
					<?php 
            _e('Order:', 'jigoshop');
            ?>
					<strong><?php 
            echo $order->get_order_number();
            ?>
</strong>
				</li>
				<li class="date">
					<?php 
            _e('Date:', 'jigoshop');
            ?>
					<strong><?php 
            echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($order->order_date));
            ?>
</strong>
				</li>
				<li class="total">
					<?php 
            _e('Total:', 'jigoshop');
            ?>
					<strong><?php 
            echo jigoshop_price($order->order_total);
            ?>
</strong>
				</li>
				<li class="method">
					<?php 
            _e('Payment method:', 'jigoshop');
            ?>
					<strong><?php 
            $gateways = jigoshop_payment_gateways::payment_gateways();
            if (isset($gateways[$order->payment_method])) {
                echo $gateways[$order->payment_method]->title;
            } else {
                echo $order->payment_method;
            }
            ?>
</strong>
				</li>
			</ul>
			<div class="clear"></div>
			<?php 
            do_action('thankyou_' . $order->payment_method, $order_id);
            do_action('jigoshop_thankyou', $order->id);
        }
    }
    echo '<p><a class="button" href="' . esc_url(jigoshop_cart::get_shop_url()) . '">' . __('&larr; Continue Shopping', 'jigoshop') . '</a></p>';
}
示例#2
0
function my_cart($atts)
{
    $errors = array();
    unset(jigoshop_session::instance()->selected_rate_id);
    // Process Discount Codes
    if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && jigoshop::verify_nonce('cart')) {
        $coupon_code = stripslashes(trim($_POST['coupon_code']));
        jigoshop_cart::add_discount($coupon_code);
        // Update Shipping
    } elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && jigoshop::verify_nonce('cart')) {
        unset(jigoshop_session::instance()->chosen_shipping_method_id);
        $country = $_POST['calc_shipping_country'];
        $state = $_POST['calc_shipping_state'];
        $postcode = $_POST['calc_shipping_postcode'];
        if ($postcode && !jigoshop_validation::is_postcode($postcode, $country)) {
            jigoshop::add_error(__('Please enter a valid postcode/ZIP.', 'jigoshop'));
            $postcode = '';
        } elseif ($postcode) {
            $postcode = jigoshop_validation::format_postcode($postcode, $country);
        }
        if ($country) {
            // Update customer location
            jigoshop_customer::set_location($country, $state, $postcode);
            jigoshop_customer::set_shipping_location($country, $state, $postcode);
            jigoshop::add_message(__('Shipping costs updated.', 'jigoshop'));
        } else {
            jigoshop_customer::set_shipping_location('', '', '');
            jigoshop::add_message(__('Shipping costs updated.', 'jigoshop'));
        }
    } elseif (isset($_POST['shipping_rates'])) {
        $rates_params = explode(":", $_POST['shipping_rates']);
        $available_methods = jigoshop_shipping::get_available_shipping_methods();
        $shipping_method = $available_methods[$rates_params[0]];
        if ($rates_params[1] != NULL) {
            jigoshop_session::instance()->selected_rate_id = $rates_params[1];
        }
        $shipping_method->choose();
        // choses the method selected by user.
    }
    // Re-Calc prices. This needs to happen every time the cart page is loaded and after checking post results. It will happen twice for coupon.
    jigoshop_cart::calculate_totals();
    $result = jigoshop_cart::check_cart_item_stock();
    if (is_wp_error($result)) {
        jigoshop::add_error($result->get_error_message());
    }
    jigoshop::show_messages();
    if (sizeof(jigoshop_cart::$cart_contents) == 0) {
        echo '<p>' . __('Your cart is empty.', 'jigoshop') . '</p>';
        ?>
<p><a href="<?php 
        echo esc_url(jigoshop_cart::get_shop_url());
        ?>
" class="button"><?php 
        _e('&larr; Return to Shop', 'jigoshop');
        ?>
</a></p><?php 
        return;
    }
    ?>
    <form action="<?php 
    echo esc_url(jigoshop_cart::get_cart_url());
    ?>
" method="post">
        <table class="shop_table cart" cellspacing="0" id="shop-cart">
            <thead>
                <tr>
                    <th class="product-remove">Remove</th>
                    <th class="product-thumbnail"></th>
                    <th class="product-name"><span class="nobr"><?php 
    _e('Product Name', 'jigoshop');
    ?>
</span></th>
                    <th class="product-price"><span class="nobr"><?php 
    _e('Unit Price', 'jigoshop');
    ?>
</span></th>
                    <th class="product-quantity"><?php 
    _e('Quantity', 'jigoshop');
    ?>
</th>
                    <th class="product-subtotal"><?php 
    _e('Price', 'jigoshop');
    ?>
</th>
                </tr>
                <?php 
    do_action('jigoshop_shop_table_cart_head');
    ?>
            </thead>
            <tbody>
                <?php 
    if (sizeof(jigoshop_cart::$cart_contents) > 0) {
        foreach (jigoshop_cart::$cart_contents as $cart_item_key => $values) {
            $_product = $values['data'];
            if ($_product->exists() && $values['quantity'] > 0) {
                $additional_description = jigoshop_cart::get_item_data($values);
                ?>
                            <tr>
                                <td class="product-remove"><a href="<?php 
                echo esc_url(jigoshop_cart::get_remove_url($cart_item_key));
                ?>
" class="remove" title="<?php 
                echo esc_attr(__('Remove this item.', 'jigoshop'));
                ?>
">&times;</a></td>
                                <td class="product-thumbnail"><a href="<?php 
                echo esc_url(apply_filters('jigoshop_product_url_display_in_cart', get_permalink($values['product_id']), $cart_item_key));
                ?>
">
                                    <?php 
                if ($values['variation_id'] && has_post_thumbnail($values['variation_id'])) {
                    echo get_the_post_thumbnail($values['variation_id'], 'shop_tiny');
                } else {
                    if (has_post_thumbnail($values['product_id'])) {
                        echo get_the_post_thumbnail($values['product_id'], 'shop_tiny');
                    } else {
                        echo '<img src="' . jigoshop::assets_url() . '/assets/images/placeholder.png" alt="Placeholder" width="' . jigoshop::get_var('shop_tiny_w') . '" height="' . jigoshop::get_var('shop_tiny_h') . '" />';
                    }
                }
                ?>
</a>
                                </td>

                                <td class="product-name">
                                    <a href="<?php 
                echo esc_url(apply_filters('jigoshop_product_url_display_in_cart', get_permalink($values['product_id']), $cart_item_key));
                ?>
"><?php 
                echo apply_filters('jigoshop_cart_product_title', $_product->get_title(), $_product);
                ?>
</a>
                                    <?php 
                echo $additional_description;
                ?>
                                    <?php 
                if (!empty($values['variation_id'])) {
                    $product_id = $values['variation_id'];
                } else {
                    $product_id = $values['product_id'];
                }
                $custom_products = (array) jigoshop_session::instance()->customized_products;
                $custom = isset($custom_products[$product_id]) ? $custom_products[$product_id] : '';
                if (!empty($custom_products[$product_id])) {
                    ?>
											<dl class="customization">
												<dt class="customized_product_label"><?php 
                    echo apply_filters('jigoshop_customized_product_label', __('Personal: ', 'jigoshop'));
                    ?>
</dt>
												<dd class="customized_product"><?php 
                    echo esc_textarea($custom);
                    ?>
</dd>
											</dl>
											<?php 
                }
                ?>
                                </td>
                                <td class="product-price"><span class="m-label">Unit price:</span><?php 
                echo jigoshop_price($_product->get_price());
                ?>
</td>
                                <td class="product-quantity">
                                    <span class="m-label">Quantity:</span>
                                     <div class="quantity"><input name="cart[<?php 
                echo $cart_item_key;
                ?>
][qty]" value="<?php 
                echo esc_attr($values['quantity']);
                ?>
" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
                                </td>
                                <td class="product-subtotal"><span class="m-label">Price:</span><?php 
                echo jigoshop_price($_product->get_price() * $values['quantity']);
                ?>
</td>
                            </tr>
                            <?php 
            }
        }
    }
    do_action('jigoshop_shop_table_cart_body');
    ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="6" class="actions">

                        <?php 
    $coupons = JS_Coupons::get_coupons();
    if (!empty($coupons)) {
        ?>
                            <div class="coupon">
                                <label for="coupon_code"><?php 
        _e('Coupon', 'jigoshop');
        ?>
:</label> <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" />
                                <input type="submit" class="button" name="apply_coupon" value="<?php 
        _e('Apply Coupon', 'jigoshop');
        ?>
" />
                            </div>
                        <?php 
    }
    ?>

                        <?php 
    jigoshop::nonce_field('cart');
    ?>
                        <input type="submit" class="button" name="update_cart" value="<?php 
    _e('Update Shopping Cart', 'jigoshop');
    ?>
" /> <a href="<?php 
    echo esc_url(jigoshop_cart::get_checkout_url());
    ?>
" class="checkout-button button-alt"><?php 
    _e('Proceed to Checkout &rarr;', 'jigoshop');
    ?>
</a>
                    </td>
                </tr>
                <?php 
    if (count(jigoshop_cart::$applied_coupons)) {
        ?>
                    <tr>
                        <td colspan="6" class="applied-coupons">
                            <div>
                                <span class="applied-coupons-label"><?php 
        _e('Applied Coupons: ', 'jigoshop');
        ?>
</span>
								<?php 
        foreach (jigoshop_cart::$applied_coupons as $code) {
            ?>
                                <a href="?unset_coupon=<?php 
            echo $code;
            ?>
" id="<?php 
            echo $code;
            ?>
" class="applied-coupons-values"><?php 
            echo $code;
            ?>
									<span class="close">&times;</span>
								</a>
								<?php 
        }
        ?>
                            </div>
                        </td>
                    </tr>
                    <?php 
    }
    do_action('jigoshop_shop_table_cart_foot');
    ?>
            </tfoot>
            <?php 
    do_action('jigoshop_shop_table_cart');
    ?>
        </table>
    </form>
    <div class="cart-collaterals">

        <?php 
    do_action('cart-collaterals');
    ?>

        <div class="cart_totals">
            <?php 
    // Hide totals if customer has set location and there are no methods going there
    $available_methods = jigoshop_shipping::get_available_shipping_methods();
    $jigoshop_options = Jigoshop_Base::get_options();
    if ($available_methods || !jigoshop_customer::get_shipping_country() || !jigoshop_shipping::is_enabled()) {
        ?>
                <h2><?php 
        _e('Cart Totals', 'jigoshop');
        ?>
</h2>

                <div class="cart_totals_table">
                    <table cellspacing="0" cellpadding="0">
                        <tbody>

                            <tr>
							   <?php 
        $price_label = jigoshop_cart::show_retail_price() ? __('Retail Price', 'jigoshop') : __('Subtotal', 'jigoshop');
        ?>

								<th class="cart-row-subtotal-title"><?php 
        echo $price_label;
        ?>
</th>
                                <td class="cart-row-subtotal"><?php 
        echo jigoshop_cart::get_cart_subtotal();
        ?>
</td>
                            </tr>

                            <?php 
        if (jigoshop_cart::get_cart_shipping_total()) {
            ?>
							<tr>
                                <th class="cart-row-shipping-title"><?php 
            _e('Shipping', 'jigoshop');
            ?>
 <small><?php 
            echo jigoshop_countries::shipping_to_prefix() . ' ' . __(jigoshop_countries::$countries[jigoshop_customer::get_shipping_country()], 'jigoshop');
            ?>
</small></th>
                                <td class="cart-row-shipping"><?php 
            echo jigoshop_cart::get_cart_shipping_total();
            ?>
 <small><?php 
            echo jigoshop_cart::get_cart_shipping_title();
            ?>
</small></td>
                            </tr>
                            <?php 
        }
        ?>

                            <?php 
        if (jigoshop_cart::show_retail_price()) {
            ?>
                                <tr>
                                    <th class="cart-row-subtotal-title"><?php 
            _e('Subtotal', 'jigoshop');
            ?>
</th>
                                    <td class="cart-row-subtotal"><?php 
            echo jigoshop_cart::get_cart_subtotal(true, true);
            ?>
</td>
                                </tr>
                            <?php 
        }
        ?>

                            <?php 
        if (jigoshop_cart::tax_after_coupon()) {
            ?>
                                <tr class="discount">
                                    <th class="cart-row-discount-title"><?php 
            _e('Discount', 'jigoshop');
            ?>
</th>
									<td class="cart-row-discount">-<?php 
            echo jigoshop_cart::get_total_discount();
            ?>
</td>
                                </tr>
                            <?php 
        }
        ?>

                            <?php 
        if (Jigoshop_Base::get_options()->get_option('jigoshop_calc_taxes') == 'yes') {
            foreach (jigoshop_cart::get_applied_tax_classes() as $tax_class) {
                if (jigoshop_cart::get_tax_for_display($tax_class)) {
                    ?>
                                        <tr>
                                            <th class="cart-row-tax-title"><?php 
                    echo jigoshop_cart::get_tax_for_display($tax_class);
                    ?>
</th>
                                            <td class="cart-row-tax"><?php 
                    echo jigoshop_cart::get_tax_amount($tax_class);
                    ?>
</td>
                                        </tr>
                                    <?php 
                }
            }
        }
        ?>

							<?php 
        if (!jigoshop_cart::tax_after_coupon() && jigoshop_cart::get_total_discount()) {
            ?>
							<tr class="discount">
								<th class="cart-row-discount-title"><?php 
            _e('Discount', 'jigoshop');
            ?>
</th>
								<td class="cart-row-discount">-<?php 
            echo jigoshop_cart::get_total_discount();
            ?>
</td>
							</tr>
							<?php 
        }
        ?>

							<tr>
								<th class="cart-row-total-title"><strong><?php 
        _e('Total', 'jigoshop');
        ?>
</strong></th>
								<td class="cart-row-total"><strong><?php 
        echo jigoshop_cart::get_total();
        ?>
</strong></td>
							</tr>

						</tbody>
					</table>
				</div>
			<?php 
    } else {
        echo '<p>' . __(jigoshop_shipping::get_shipping_error_message(), 'jigoshop') . '</p>';
    }
    ?>
		</div>

		<?php 
    jigoshop_shipping_calculator();
    ?>

	</div>
	<?php 
}
 function jigoshop_breadcrumb($delimiter = ' &rsaquo; ', $wrap_before = '<div id="breadcrumb">', $wrap_after = '</div>', $before = '', $after = '', $home = null)
 {
     global $post, $wp_query, $author;
     $options = Jigoshop_Base::get_options();
     if (!$home) {
         $home = _x('Home', 'breadcrumb', 'jigoshop');
     }
     $home_link = home_url();
     $prepend = '';
     if ($options->get('jigoshop_prepend_shop_page_to_urls') == "yes" && jigoshop_get_page_id('shop') && get_option('page_on_front') !== jigoshop_get_page_id('shop')) {
         $prepend = $before . '<a href="' . esc_url(jigoshop_cart::get_shop_url()) . '">' . get_the_title(jigoshop_get_page_id('shop')) . '</a> ' . $after . $delimiter;
     }
     if (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('page_on_front') == jigoshop_get_page_id('shop')) || is_paged()) {
         echo $wrap_before;
         echo $before . '<a class="home" href="' . $home_link . '">' . $home . '</a> ' . $after . $delimiter;
         if (is_category()) {
             $cat_obj = $wp_query->get_queried_object();
             $this_category = $cat_obj->term_id;
             $this_category = get_category($this_category);
             if ($this_category->parent != 0) {
                 $parent_category = get_category($this_category->parent);
                 echo get_category_parents($parent_category->term_id, true, $delimiter);
             }
             echo $before . single_cat_title('', false) . $after;
         } elseif (is_tax('product_cat')) {
             $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
             $parents = array();
             $parent = $term->parent;
             while ($parent) {
                 $parents[] = $parent;
                 $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
                 $parent = $new_parent->parent;
             }
             if (!empty($parents)) {
                 $parents = array_reverse($parents);
                 foreach ($parents as $parent) {
                     $item = get_term_by('id', $parent, get_query_var('taxonomy'));
                     echo $before . '<a href="' . get_term_link($item->slug, 'product_cat') . '">' . $item->name . '</a>' . $after . $delimiter;
                 }
             }
             $queried_object = $wp_query->get_queried_object();
             echo $prepend . $before . $queried_object->name . $after;
         } elseif (is_tax('product_tag')) {
             $queried_object = $wp_query->get_queried_object();
             echo $prepend . $before . __('Products tagged &ldquo;', 'jigoshop') . $queried_object->name . '&rdquo;' . $after;
         } elseif (is_day()) {
             echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $after . $delimiter;
             echo $before . '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $after . $delimiter;
             echo $before . get_the_time('d') . $after;
         } elseif (is_month()) {
             echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $after . $delimiter;
             echo $before . get_the_time('F') . $after;
         } elseif (is_year()) {
             echo $before . get_the_time('Y') . $after;
         } elseif (is_post_type_archive('product') && get_option('page_on_front') !== jigoshop_get_page_id('shop')) {
             $_name = jigoshop_get_page_id('shop') ? get_the_title(jigoshop_get_page_id('shop')) : ucwords($options->get('jigoshop_shop_slug'));
             if (is_search()) {
                 echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . $_name . '</a>' . $delimiter . __('Search results for &ldquo;', 'jigoshop') . get_search_query() . '&rdquo;' . $after;
             } else {
                 echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . $_name . '</a>' . $after;
             }
         } elseif (is_single() && !is_attachment()) {
             if (get_post_type() == 'product') {
                 echo $prepend;
                 if ($terms = get_the_terms($post->ID, 'product_cat')) {
                     $term = apply_filters('jigoshop_product_cat_breadcrumb_terms', current($terms), $terms);
                     $parents = array();
                     $parent = $term->parent;
                     while ($parent) {
                         $parents[] = $parent;
                         $new_parent = get_term_by('id', $parent, 'product_cat');
                         $parent = $new_parent->parent;
                     }
                     if (!empty($parents)) {
                         $parents = array_reverse($parents);
                         foreach ($parents as $parent) {
                             $item = get_term_by('id', $parent, 'product_cat');
                             echo $before . '<a href="' . get_term_link($item->slug, 'product_cat') . '">' . $item->name . '</a>' . $after . $delimiter;
                         }
                     }
                     echo $before . '<a href="' . get_term_link($term->slug, 'product_cat') . '">' . $term->name . '</a>' . $after . $delimiter;
                 }
                 echo $before . get_the_title() . $after;
             } elseif (get_post_type() != 'post') {
                 $post_type = get_post_type_object(get_post_type());
                 echo $before . '<a href="' . get_post_type_archive_link(get_post_type()) . '">' . $post_type->labels->singular_name . '</a>' . $after . $delimiter;
                 echo $before . get_the_title() . $after;
             } else {
                 $cat = current(get_the_category());
                 echo get_category_parents($cat, true, $delimiter);
                 echo $before . get_the_title() . $after;
             }
         } elseif (is_404()) {
             echo $before . __('Error 404', 'jigoshop') . $after;
         } elseif (!is_single() && !is_page() && get_post_type() != 'post') {
             $post_type = get_post_type_object(get_post_type());
             if ($post_type) {
                 echo $before . $post_type->labels->singular_name . $after;
             }
         } elseif (is_attachment()) {
             $parent = get_post($post->post_parent);
             $cat = get_the_category($parent->ID);
             $cat = $cat[0];
             echo get_category_parents($cat, true, '' . $delimiter);
             echo $before . '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $after . $delimiter;
             echo $before . get_the_title() . $after;
         } elseif (is_page() && !$post->post_parent) {
             echo $before . get_the_title() . $after;
         } elseif (is_page() && $post->post_parent) {
             $parent_id = $post->post_parent;
             $breadcrumbs = array();
             while ($parent_id) {
                 $page = get_post($parent_id);
                 $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                 $parent_id = $page->post_parent;
             }
             $breadcrumbs = array_reverse($breadcrumbs);
             foreach ($breadcrumbs as $crumb) {
                 echo $crumb . '' . $delimiter;
             }
             echo $before . get_the_title() . $after;
         } elseif (is_search()) {
             echo $before . __('Search results for &ldquo;', 'jigoshop') . get_search_query() . '&rdquo;' . $after;
         } elseif (is_tag()) {
             echo $before . __('Posts tagged &ldquo;', 'jigoshop') . single_tag_title('', false) . '&rdquo;' . $after;
         } elseif (is_author()) {
             $userdata = get_userdata($author);
             echo $before . __('Author: ', 'jigoshop') . $userdata->display_name . $after;
         }
         if (get_query_var('paged')) {
             echo ' (' . __('Page', 'jigoshop') . ' ' . get_query_var('paged') . ')';
         }
         echo $wrap_after;
     }
 }
示例#4
0
						<?php 
        }
        ?>
					</div>
				</td>
			</tr>
		<?php 
    }
    ?>
		<?php 
    if ($options->get('jigoshop_cart_shows_shop_button') == 'yes') {
        ?>
			<tr>
				<td colspan="6" class="actions">
					<a href="<?php 
        echo esc_url(jigoshop_cart::get_shop_url());
        ?>
" class="checkout-button button-alt" style="float:left;"><?php 
        _e('&larr; Return to Shop', 'jigoshop');
        ?>
</a>
					<a href="<?php 
        echo esc_url(jigoshop_cart::get_checkout_url());
        ?>
" class="checkout-button button-alt"><?php 
        _e('Proceed to Checkout &rarr;', 'jigoshop');
        ?>
</a>
				</td>
			</tr>
		<?php