/**
  * @param int $order_id
  * @return array
  */
 function process_payment($order_id)
 {
     $order = new jigoshop_order($order_id);
     $this->init_paymentwall_configs();
     $return = array('result' => 'fail', 'redirect' => '');
     $charge = new Paymentwall_Charge();
     try {
         $charge->create(array_merge($this->prepare_user_profile_data($order), $this->prepare_card_info($order)));
         $response = $charge->getPublicData();
         if ($charge->isSuccessful()) {
             if ($charge->isCaptured()) {
                 // Add order note
                 $order->add_order_note(sprintf(__('Brick payment approved (ID: %s, Card: xxxx-%s)', PW_JIGO_TEXT_DOMAIN), $charge->getId(), $charge->getCard()->getAlias()));
                 // Payment complete
                 $order->payment_complete();
                 $return['result'] = 'success';
                 $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
                 $return['redirect'] = add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink($checkout_redirect)));
             } elseif ($charge->isUnderReview()) {
                 $order->update_status('on-hold');
             }
             // Clear shopping cart
             jigoshop_cart::empty_cart();
         } else {
             $errors = json_decode($response, true);
             jigoshop::add_error(__($errors['error']['message']), 'error');
         }
     } catch (Exception $e) {
         jigoshop::add_error($e->getMessage(), 'error');
     }
     // Return redirect
     return $return;
 }
 function successful_request($posted)
 {
     $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
     if (!empty($posted['f_code'])) {
         $order = new jigoshop_order((int) $posted['mer_txn']);
         if ($order->status !== 'completed') {
             switch ($posted['f_code']) {
                 case 'Ok':
                     $order->add_order_note(__('Atom Standard payment completed', 'jigoshop'));
                     $order->payment_complete();
                     wp_safe_redirect(add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(jigoshop_get_page_id('thanks')))));
                     exit;
                     // case '0' : // Pending
                     // case '-2' : // Failed
                     // $order->update_status('on-hold', sprintf(__('Atom payment failed (%s)', 'jigoshop'), strtolower($posted['status']) ) );
                     // break;
                 // case '0' : // Pending
                 // case '-2' : // Failed
                 // $order->update_status('on-hold', sprintf(__('Atom payment failed (%s)', 'jigoshop'), strtolower($posted['status']) ) );
                 // break;
                 case 'F':
                     $order->update_status('cancelled', __('Atom payment cancelled', 'jigoshop'));
                     break;
                 default:
                     $order->update_status('cancelled', __('Atom exception', 'jigoshop'));
                     break;
             }
         }
         exit;
     }
 }
Ejemplo n.º 3
0
 /**
  * Widget
  * Display the widget in the sidebar
  * Save output to the cache if empty
  *
  * @param  array  sidebar arguments
  * @param  array  instance
  */
 public function widget($args, $instance)
 {
     extract($args);
     // Print the widget wrapper
     echo $before_widget;
     if (is_user_logged_in()) {
         // Get current user instance
         global $current_user;
         // Print title
         $title = $instance['title_user'] ? $instance['title_user'] : __('Hey %s!', 'jigoshop');
         if ($title) {
             echo $before_title . sprintf($title, ucwords($current_user->display_name)) . $after_title;
         }
         // Create the default set of links
         $links = apply_filters('jigoshop_widget_logout_user_links', array(__('My Account', 'jigoshop') => get_permalink(jigoshop_get_page_id('myaccount')), __('Change Password', 'jigoshop') => get_permalink(jigoshop_get_page_id('change_password')), __('Logout', 'jigoshop') => wp_logout_url(home_url())));
     } else {
         // Print title
         $title = $instance['title_guest'] ? $instance['title_guest'] : __('Login', 'jigoshop');
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         do_action('jigoshop_widget_login_before_form');
         // Get redirect URI
         $redirect_to = apply_filters('jigoshop_widget_login_redirect', get_permalink(jigoshop_get_page_id('myaccount')));
         $fields = array();
         // Support for other plugins which uses GET parameters
         $fields = apply_filters('jigoshop_get_hidden_fields', $fields);
         echo "<form action='" . esc_url(wp_login_url($redirect_to)) . "' method='post' class='jigoshop_login_widget'>";
         foreach ($fields as $key => $value) {
             echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
         }
         // Username
         echo "\n\t\t\t<p>\n\t\t\t\t<label for='log'>" . __('Username', 'jigoshop') . "</label>\n\t\t\t\t<input type='text' name='log' id='log' class='input-text username' />\n\t\t\t</p>\n\t\t\t";
         // Password
         echo "\n\t\t\t<p>\n\t\t\t\t<label for='pwd'>" . __('Password', 'jigoshop') . "</label>\n\t\t\t\t<input type='password' name='pwd' id='pwd' class='input-text password' />\n\t\t\t</p>\n\t\t\t";
         echo "\n\t\t\t<p>\n\t\t\t\t<input type='submit' name='submit' value='" . __('Login', 'jigoshop') . "' class='input-submit' />\n\t\t\t\t<a class='forgot' href='" . esc_url(wp_lostpassword_url($redirect_to)) . "'>" . __('Forgot it?', 'jigoshop') . "</a>\n\t\t\t</p>\n\t\t\t";
         if (Jigoshop_Base::get_options()->get('jigoshop_enable_signup_form') == 'yes') {
             echo '<p class="register">';
             wp_register(__('New user?', 'jigoshop') . ' ', '');
             echo '</p>';
         }
         echo "</form>";
         do_action('jigoshop_widget_login_after_form');
         $links = apply_filters('jigoshop_widget_login_user_links', array());
     }
     // Loop & print out the links
     if ($links) {
         echo "\n\t\t\t<nav role='navigation'>\n\t\t\t\t<ul class='pagenav'>";
         foreach ($links as $title => $href) {
             $href = esc_url($href);
             echo "<li><a title='Go to {$title}' href='{$href}'>{$title}</a></li>";
         }
         echo "\n\t\t\t\t</ul>\n\t\t\t</nav>";
     }
     // Print closing widget wrapper
     echo $after_widget;
 }
Ejemplo n.º 4
0
 /**
  * Process the payment and return the result
  **/
 function process_payment($order_id)
 {
     $order = new jigoshop_order($order_id);
     // Mark as on-hold (we're awaiting the cheque)
     $order->update_status('waiting-for-payment', __('Awaiting cheque payment', 'jigoshop'));
     // Remove cart
     jigoshop_cart::empty_cart();
     // Return thankyou redirect
     $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
     return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink($checkout_redirect))));
 }
Ejemplo n.º 5
0
 /**
  * Process the payment and return the result
  **/
 function process_payment($order_id)
 {
     $order = new jigoshop_order($order_id);
     $status = Jigoshop_Base::get_options()->get('jigoshop_cod_status', 'processing');
     $order->update_status($status, __('Waiting for cash delivery.', 'jigoshop'));
     // Remove cart
     jigoshop_cart::empty_cart();
     // Return thankyou redirect
     $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
     return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink($checkout_redirect))));
 }
Ejemplo n.º 6
0
 public function menu_item()
 {
     $total = 0;
     if (!empty(jigoshop_cart::$cart_contents)) {
         foreach (jigoshop_cart::$cart_contents as $cart_item_key => $values) {
             $product = $values['data'];
             $total += $product->get_price() * $values['quantity'];
         }
     }
     $total = jigoshop_price($total);
     $menu_item = array('cart_url' => jigoshop_cart::get_cart_url(), 'shop_page_url' => get_permalink(jigoshop_get_page_id('shop')), 'cart_contents_count' => jigoshop_cart::$cart_contents_count, 'cart_total' => $total);
     return $menu_item;
 }
Ejemplo n.º 7
0
function jigoshop_edit_address()
{
    $account_url = get_permalink(jigoshop_get_page_id(JIGOSHOP_MY_ACCOUNT));
    $user_id = get_current_user_id();
    $load_address = jigoshop_get_address_to_edit();
    $address = jigoshop_get_address_fields($load_address, $user_id);
    if (isset($_POST['save_address']) && jigoshop::verify_nonce(JIGOSHOP_EDIT_ADDRESS)) {
        if ($user_id > 0) {
            foreach ($address as &$field) {
                if (isset($_POST[$field['name']])) {
                    $field['value'] = jigowatt_clean($_POST[$field['name']]);
                    update_user_meta($user_id, $field['name'], $field['value']);
                }
            }
            do_action('jigoshop_user_edit_address', $user_id, $address);
        }
    }
    jigoshop_render('shortcode/my_account/edit_address', array('url' => add_query_arg('address', $load_address, apply_filters('jigoshop_get_edit_address_page_id', get_permalink(jigoshop_get_page_id(JIGOSHOP_EDIT_ADDRESS)))), 'account_url' => $account_url, 'load_address' => $load_address, 'address' => $address));
}
Ejemplo n.º 8
0
function jigoshop_process_checkout()
{
    if (!is_checkout() || is_jigoshop_single_page(JIGOSHOP_PAY)) {
        return;
    }
    if (count(jigoshop_cart::get_cart()) == 0) {
        wp_safe_redirect(get_permalink(jigoshop_get_page_id('cart')));
        exit;
    }
    /** @var jigoshop_checkout $_checkout */
    $_checkout = jigoshop_checkout::instance();
    $result = $_checkout->process_checkout();
    if (isset($result['result']) && $result['result'] === 'success') {
        wp_safe_redirect(apply_filters('jigoshop_is_ajax_payment_successful', $result['redirect']));
        exit;
    }
    if (isset($result['redirect'])) {
        wp_safe_redirect(get_permalink($result['redirect']));
        exit;
    }
}
Ejemplo n.º 9
0
    /**
     * Widget
     * Display the widget in the sidebar
     * Save output to the cache if empty
     *
     * @param  array  sidebar arguments
     * @param  array  instance
     */
    public function widget($args, $instance)
    {
        // Otherwise Start buffering and output the Widget
        ob_start();
        extract($args);
        // Set the widget title
        $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Product Categories', 'jigoshop'), $instance, $this->id_base);
        // Get options
        $count = (bool) isset($instance['count']) ? $instance['count'] : false;
        $is_hierarchial = (bool) isset($instance['hierarchical']) ? $instance['hierarchical'] : false;
        $is_dropdown = (bool) isset($instance['dropdown']) ? $instance['dropdown'] : false;
        // Print the widget wrapper & title
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        // Define options for the list
        $args = array('orderby' => 'name', 'show_count' => $count, 'hierarchical' => $is_hierarchial, 'taxonomy' => 'product_cat', 'title_li' => null);
        if (is_product()) {
            global $post;
            $categories = get_the_terms($post->ID, 'product_cat');
            if (!empty($categories)) {
                foreach ($categories as $id => $cat) {
                    $args['current_category'] = apply_filters('jigoshop_product_cat_widget_terms', $cat->term_id, $categories);
                    break;
                    // we can only take the first one
                }
            }
        }
        // Output as dropdown or unordered list
        if ($is_dropdown) {
            // Set up arguments
            $args['name'] = 'dropdown_product_cat';
            // Print dropdown
            // wp_dropdown_categories($args); Commented out due to wordpress bug 13258 not supporting custom taxonomies
            // See: http://core.trac.wordpress.org/ticket/13258
            jigoshop_product_dropdown_categories($args['show_count'], $args['hierarchical']);
            // TODO: Move this javascript to its own file (plugins.js?)
            ?>
			<script type='text/javascript'>
				/* <![CDATA[ */
				var dropdown = document.getElementById("dropdown_product_cat");
				function onCatChange(){
					if(dropdown.options[dropdown.selectedIndex].value !== ''){
						location.href = "<?php 
            echo home_url();
            ?>
/?product_cat=" + dropdown.options[dropdown.selectedIndex].value;
					} else {
						location.href = "<?php 
            echo get_permalink(jigoshop_get_page_id('shop'));
            ?>
"
					}
				}
				dropdown.onchange = onCatChange;
				/* ]]> */
			</script>
		<?php 
        } else {
            // Print list of categories
            echo '<ul>';
            wp_list_categories(apply_filters('widget_product_categories_args', $args));
            echo '</ul>';
        }
        // Print closing widget wrapper
        echo $after_widget;
        // Flush output buffer and save to transient cache
        $result = ob_get_flush();
        $cache[$this->id] = $result;
        set_transient('jigoshop_widget_cache', $cache, 3600 * 3);
        // 3 hours ahead
    }
 function process_payment($order_id)
 {
     $order = new jigoshop_order($order_id);
     return array('result' => 'success', 'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(jigoshop_get_page_id('pay')))));
 }
Ejemplo n.º 11
0
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="wrapper">
            <div class="row-fluid">
                <div class="span12">
                    <h3><?php 
if (is_search()) {
    _e('Search', kopa_get_domain());
} elseif (is_tax('product_cat') || is_tax('product_tag')) {
    $queried_object = get_queried_object();
    echo $queried_object->name;
} elseif (is_post_type_archive('product') && jigoshop_get_page_id('shop')) {
    echo get_the_title(jigoshop_get_page_id('shop'));
} else {
    single_post_title();
}
?>
</h3>

                    <?php 
kopa_breadcrumb();
?>

                </div><!--span12-->
            </div><!--row-fluid-->
        </div><!--wrapper-->
    </div><!--page-title-->
</div><!--page-title-wrapper-->
Ejemplo n.º 12
0
function jigoshop_page_body_classes()
{
    global $jigoshop_body_classes;
    $jigoshop_body_classes = (array) $jigoshop_body_classes;
    if (is_order_tracker()) {
        jigoshop_add_body_class(array('jigoshop', 'jigoshop-tracker'));
    }
    if (is_checkout()) {
        jigoshop_add_body_class(array('jigoshop', 'jigoshop-checkout'));
    }
    if (is_cart()) {
        jigoshop_add_body_class(array('jigoshop', 'jigoshop-cart'));
    }
    if (is_page(jigoshop_get_page_id('thanks'))) {
        jigoshop_add_body_class(array('jigoshop', 'jigoshop-thanks'));
    }
    if (is_page(jigoshop_get_page_id('pay'))) {
        jigoshop_add_body_class(array('jigoshop', 'jigoshop-pay'));
    }
    if (is_account()) {
        jigoshop_add_body_class(array('jigoshop', 'jigoshop-myaccount'));
    }
}
Ejemplo n.º 13
0
 private function process_gateway_html_form($order)
 {
     // Return pay page redirect
     return array('result' => 'success', 'redirect' => add_query_arg(array('order' => $order->id, 'key' => $order->order_key), get_permalink(jigoshop_get_page_id('pay'))));
 }
 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;
     }
 }
Ejemplo n.º 15
0
 /**
  * Generate the paypal button link
  *
  * @param int $order_id
  * @return string
  */
 public function generate_paypal_form($order_id)
 {
     $order = new jigoshop_order($order_id);
     if ($this->testmode == 'yes') {
         $url = $this->testurl . '?test_ipn=1&';
     } else {
         $url = $this->liveurl . '?';
     }
     if (in_array($order->billing_country, array('US', 'CA'))) {
         $order->billing_phone = str_replace(array('(', '-', ' ', ')'), '', $order->billing_phone);
         $phone_args = array('night_phone_a' => substr($order->billing_phone, 0, 3), 'night_phone_b' => substr($order->billing_phone, 3, 3), 'night_phone_c' => substr($order->billing_phone, 6, 4), 'day_phone_a' => substr($order->billing_phone, 0, 3), 'day_phone_b' => substr($order->billing_phone, 3, 3), 'day_phone_c' => substr($order->billing_phone, 6, 4));
     } else {
         $phone_args = array('night_phone_b' => $order->billing_phone, 'day_phone_b' => $order->billing_phone);
     }
     // filter redirect page
     $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
     $paypal_args = array_merge(array('cmd' => '_cart', 'business' => $this->testmode == 'yes' ? $this->testemail : $this->email, 'no_note' => 1, 'currency_code' => Jigoshop_Base::get_options()->get('jigoshop_currency'), 'charset' => 'UTF-8', 'rm' => 2, 'upload' => 1, 'return' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink($checkout_redirect))), 'cancel_return' => $order->get_cancel_order_url(), 'custom' => $order_id, 'notify_url' => $this->notify_url, 'first_name' => $order->billing_first_name, 'last_name' => $order->billing_last_name, 'company' => $order->billing_company, 'address1' => $order->billing_address_1, 'address2' => $order->billing_address_2, 'city' => $order->billing_city, 'state' => $order->billing_state, 'zip' => $order->billing_postcode, 'country' => $order->billing_country, 'email' => $order->billing_email, 'invoice' => $order->get_order_number(), 'amount' => number_format((double) $order->order_total, $this->decimals), 'bn' => 'Jigoshop_SP'), $phone_args);
     if ($this->send_shipping == 'yes') {
         $paypal_args['no_shipping'] = 1;
         $paypal_args['address_override'] = 1;
         $paypal_args['first_name'] = $order->shipping_first_name;
         $paypal_args['last_name'] = $order->shipping_last_name;
         $paypal_args['address1'] = $order->shipping_address_1;
         $paypal_args['address2'] = $order->shipping_address_2;
         $paypal_args['city'] = $order->shipping_city;
         $paypal_args['state'] = $order->shipping_state;
         $paypal_args['zip'] = $order->shipping_postcode;
         $paypal_args['country'] = $order->shipping_country;
         // PayPal counts Puerto Rico as a US Territory, won't allow payment without it
         if ($paypal_args['country'] == 'PR') {
             $paypal_args['country'] = 'US';
             $paypal_args['state'] = 'PR';
         }
     } else {
         $paypal_args['no_shipping'] = 1;
         $paypal_args['address_override'] = 0;
     }
     // If prices include tax, send the whole order as a single item
     if (Jigoshop_Base::get_options()->get('jigoshop_prices_include_tax') == 'yes') {
         // Discount
         $paypal_args['discount_amount_cart'] = number_format((double) $order->order_discount, $this->decimals);
         // Don't pass items - PayPal breaks tax due to catalog prices include tax.
         // PayPal has no option for tax inclusive pricing.
         // Pass 1 item for the order items overall
         $item_names = array();
         foreach ($order->items as $item) {
             $_product = $order->get_product_from_item($item);
             $title = $_product->get_title();
             //if variation, insert variation details into product title
             if ($_product instanceof jigoshop_product_variation) {
                 $title .= ' (' . jigoshop_get_formatted_variation($_product, $item['variation'], true) . ')';
             }
             $item_names[] = $title . ' x ' . $item['qty'];
         }
         $paypal_args['item_name_1'] = sprintf(__('Order %s', 'jigoshop'), $order->get_order_number()) . ' - ' . implode(', ', $item_names);
         $paypal_args['quantity_1'] = 1;
         $paypal_args['amount_1'] = number_format($order->order_total - $order->order_shipping - $order->order_shipping_tax + $order->order_discount, $this->decimals, '.', '');
         if ($order->order_shipping + $order->order_shipping_tax > 0) {
             $paypal_args['item_name_2'] = __('Shipping cost', 'jigoshop');
             $paypal_args['quantity_2'] = '1';
             $paypal_args['amount_2'] = number_format($order->order_shipping + $order->order_shipping_tax, $this->decimals, '.', '');
         }
     } else {
         // Cart Contents
         $item_loop = 0;
         foreach ($order->items as $item) {
             $_product = $order->get_product_from_item($item);
             if ($_product->exists() && $item['qty']) {
                 $item_loop++;
                 $title = $_product->get_title();
                 //if variation, insert variation details into product title
                 if ($_product instanceof jigoshop_product_variation) {
                     $title .= ' (' . jigoshop_get_formatted_variation($_product, $item['variation'], true) . ')';
                 }
                 $paypal_args['item_name_' . $item_loop] = $title;
                 $paypal_args['quantity_' . $item_loop] = $item['qty'];
                 $paypal_args['amount_' . $item_loop] = number_format(apply_filters('jigoshop_paypal_adjust_item_price', $item['cost'], $item, 10, 2), $this->decimals);
                 //Apparently, Paypal did not like "28.4525" as the amount. Changing that to "28.45" fixed the issue.
             }
         }
         // Shipping Cost
         if (jigoshop_shipping::is_enabled() && $order->order_shipping > 0) {
             $item_loop++;
             $paypal_args['item_name_' . $item_loop] = __('Shipping cost', 'jigoshop');
             $paypal_args['quantity_' . $item_loop] = '1';
             $paypal_args['amount_' . $item_loop] = number_format((double) $order->order_shipping, $this->decimals);
         }
         $paypal_args['tax'] = $order->get_total_tax(false, false);
         // no currency sign or pricing options for separators
         $paypal_args['tax_cart'] = $order->get_total_tax(false, false);
         // no currency sign or pricing options for separators
         $paypal_args['discount_amount_cart'] = $order->order_discount;
         if ($this->force_payment == 'yes') {
             $sum = 0;
             for ($i = 1; $i < $item_loop; $i++) {
                 $sum += $paypal_args['amount_' . $i];
             }
             $item_loop++;
             if ($sum == 0 || $order->order_discount && $sum - $order->order_discount == 0) {
                 $paypal_args['item_name_' . $item_loop] = __('Force payment on free', 'jigoshop');
                 $paypal_args['quantity_' . $item_loop] = '1';
                 $paypal_args['amount_' . $item_loop] = 0.01;
                 // force payment
             }
         }
     }
     $paypal_args = apply_filters('jigoshop_paypal_args', $paypal_args);
     return jigoshop_render_result('gateways/paypal', array('url' => $url, 'fields' => $paypal_args));
 }
 /**
  * Validate the checkout
  */
 public function validate_checkout()
 {
     if (jigoshop_cart::is_empty()) {
         jigoshop::add_error(sprintf(__('Sorry, your session has expired. <a href="%s">Return to homepage &rarr;</a>', 'jigoshop'), home_url()));
     }
     // Process Discount Codes
     if (!empty($_POST['coupon_code'])) {
         $coupon = sanitize_title($_POST['coupon_code']);
         jigoshop_cart::add_discount($coupon);
     }
     foreach (jigoshop_cart::get_coupons() as $coupon) {
         jigoshop_cart::is_valid_coupon($coupon);
     }
     // Checkout fields
     $this->posted['shipping_method'] = '';
     $this->posted['shipping_service'] = '';
     if (isset($_POST['shipping_method'])) {
         $shipping_method = jigowatt_clean($_POST['shipping_method']);
         $shipping_data = explode(':', $shipping_method);
         $this->posted['shipping_method'] = $shipping_data[0];
         $this->posted['shipping_service'] = $shipping_data[1];
     }
     $this->posted['shiptobilling'] = isset($_POST['shiptobilling']) ? jigowatt_clean($_POST['shiptobilling']) : '';
     $this->posted['payment_method'] = isset($_POST['payment_method']) ? jigowatt_clean($_POST['payment_method']) : '';
     $this->posted['order_comments'] = isset($_POST['order_comments']) ? jigowatt_clean($_POST['order_comments']) : '';
     $this->posted['terms'] = isset($_POST['terms']) ? jigowatt_clean($_POST['terms']) : '';
     $this->posted['create_account'] = isset($_POST['create_account']) ? jigowatt_clean($_POST['create_account']) : '';
     $this->posted['account_username'] = isset($_POST['account_username']) ? jigowatt_clean($_POST['account_username']) : '';
     $this->posted['account_password'] = isset($_POST['account_password']) ? jigowatt_clean($_POST['account_password']) : '';
     $this->posted['account_password_2'] = isset($_POST['account_password_2']) ? jigowatt_clean($_POST['account_password_2']) : '';
     if (jigoshop_cart::get_total(false) == 0) {
         $this->posted['payment_method'] = 'no_payment';
     }
     // establish customer billing and shipping locations
     if (jigoshop_cart::ship_to_billing_address_only()) {
         $this->posted['shiptobilling'] = 'true';
     }
     $country = isset($_POST['billing_country']) ? jigowatt_clean($_POST['billing_country']) : '';
     $state = isset($_POST['billing_state']) ? jigowatt_clean($_POST['billing_state']) : '';
     $allowed_countries = Jigoshop_Base::get_options()->get('jigoshop_allowed_countries');
     if ($allowed_countries === 'specific') {
         $specific_countries = Jigoshop_Base::get_options()->get('jigoshop_specific_allowed_countries');
         if (!in_array($country, $specific_countries)) {
             jigoshop::add_error(__('Invalid billing country.', 'jigoshop'));
             return;
         }
     }
     if (jigoshop_countries::country_has_states($country)) {
         $states = jigoshop_countries::get_states($country);
         if (!in_array($state, array_keys($states))) {
             jigoshop::add_error(__('Invalid billing state.', 'jigoshop'));
             return;
         }
     }
     $postcode = isset($_POST['billing_postcode']) ? jigowatt_clean($_POST['billing_postcode']) : '';
     $ship_to_billing = Jigoshop_Base::get_options()->get('jigoshop_ship_to_billing_address_only') == 'yes';
     jigoshop_customer::set_location($country, $state, $postcode);
     if (Jigoshop_Base::get_options()->get('jigoshop_calc_shipping') == 'yes') {
         if ($ship_to_billing || !empty($_POST['shiptobilling'])) {
             jigoshop_customer::set_shipping_location($country, $state, $postcode);
         } else {
             $country = isset($_POST['shipping_country']) ? jigowatt_clean($_POST['shipping_country']) : '';
             $state = isset($_POST['shipping_state']) ? jigowatt_clean($_POST['shipping_state']) : '';
             $postcode = isset($_POST['shipping_postcode']) ? jigowatt_clean($_POST['shipping_postcode']) : '';
             if ($allowed_countries === 'specific') {
                 $specific_countries = Jigoshop_Base::get_options()->get('jigoshop_specific_allowed_countries');
                 if (!in_array($country, $specific_countries)) {
                     jigoshop::add_error(__('Invalid shipping country.', 'jigoshop'));
                     return;
                 }
             }
             if (jigoshop_countries::country_has_states($country)) {
                 $states = jigoshop_countries::get_states($country);
                 if (!in_array($state, array_keys($states))) {
                     jigoshop::add_error(__('Invalid shipping state.', 'jigoshop'));
                     return;
                 }
             }
             jigoshop_customer::set_shipping_location($country, $state, $postcode);
         }
     }
     // Billing Information
     foreach ($this->billing_fields as $field) {
         $field = apply_filters('jigoshop_billing_field', $field);
         $this->posted[$field['name']] = isset($_POST[$field['name']]) ? jigowatt_clean($_POST[$field['name']]) : '';
         // Format
         if (isset($field['format'])) {
             switch ($field['format']) {
                 case 'postcode':
                     $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']]));
                     break;
             }
         }
         // Required
         if ($field['name'] == 'billing_state' && jigoshop_customer::has_valid_shipping_state()) {
             $field['required'] = false;
         }
         if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) {
             jigoshop::add_error($field['label'] . __(' (billing) is a required field.', 'jigoshop'));
         }
         if ($field['name'] == 'billing_euvatno') {
             $vatno = isset($this->posted['billing_euvatno']) ? $this->posted['billing_euvatno'] : '';
             $vatno = str_replace(' ', '', $vatno);
             $country = jigoshop_tax::get_customer_country();
             // strip any country code from the beginning of the number
             if (strpos($vatno, $country) === 0) {
                 $vatno = substr($vatno, strlen($country));
             }
             if ($vatno != '') {
                 $url = 'http://isvat.appspot.com/' . $country . '/' . $vatno . '/';
                 $httpRequest = curl_init();
                 curl_setopt($httpRequest, CURLOPT_FAILONERROR, true);
                 curl_setopt($httpRequest, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($httpRequest, CURLOPT_HEADER, false);
                 curl_setopt($httpRequest, CURLOPT_URL, $url);
                 $result = curl_exec($httpRequest);
                 curl_close($httpRequest);
                 if ($result === 'false') {
                     jigoshop_log('EU VAT validation error with URL: ' . $url);
                     jigoshop::add_error($field['label'] . __(' (billing) is not a valid VAT Number.  Leave it blank to disable VAT validation. (VAT may be charged depending on your location)', 'jigoshop'));
                 } else {
                     $this->valid_euvatno = jigoshop_countries::get_base_country() != jigoshop_tax::get_customer_country() && jigoshop_countries::is_eu_country(jigoshop_tax::get_customer_country());
                 }
             }
         }
         // Validation
         if (isset($field['validate']) && !empty($this->posted[$field['name']])) {
             switch ($field['validate']) {
                 case 'phone':
                     if (!jigoshop_validation::is_phone($this->posted[$field['name']])) {
                         jigoshop::add_error($field['label'] . __(' (billing) is not a valid number.', 'jigoshop'));
                     }
                     break;
                 case 'email':
                     if (!jigoshop_validation::is_email($this->posted[$field['name']])) {
                         jigoshop::add_error($field['label'] . __(' (billing) is not a valid email address.', 'jigoshop'));
                     }
                     break;
                 case 'postcode':
                     if (!jigoshop_validation::is_postcode($this->posted[$field['name']], $_POST['billing_country'])) {
                         jigoshop::add_error($field['label'] . __(' (billing) is not a valid postcode/ZIP.', 'jigoshop'));
                     } else {
                         $this->posted[$field['name']] = jigoshop_validation::format_postcode($this->posted[$field['name']], $_POST['billing_country']);
                     }
                     break;
             }
         }
     }
     // Shipping Information
     if (jigoshop_shipping::is_enabled() && !jigoshop_cart::ship_to_billing_address_only() && empty($this->posted['shiptobilling'])) {
         foreach ($this->shipping_fields as $field) {
             $field = apply_filters('jigoshop_shipping_field', $field);
             if (isset($_POST[$field['name']])) {
                 $this->posted[$field['name']] = jigowatt_clean($_POST[$field['name']]);
             } else {
                 $this->posted[$field['name']] = '';
             }
             // Format
             if (isset($field['format'])) {
                 switch ($field['format']) {
                     case 'postcode':
                         $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']]));
                         break;
                 }
             }
             // Required
             if ($field['name'] == 'shipping_state' && jigoshop_customer::has_valid_shipping_state()) {
                 $field['required'] = false;
             }
             if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) {
                 jigoshop::add_error($field['label'] . __(' (shipping) is a required field.', 'jigoshop'));
             }
             // Validation
             if (isset($field['validate']) && !empty($this->posted[$field['name']])) {
                 switch ($field['validate']) {
                     case 'postcode':
                         if (!jigoshop_validation::is_postcode($this->posted[$field['name']], $country)) {
                             jigoshop::add_error($field['label'] . __(' (shipping) is not a valid postcode/ZIP.', 'jigoshop'));
                         } else {
                             $this->posted[$field['name']] = jigoshop_validation::format_postcode($this->posted[$field['name']], $country);
                         }
                         break;
                 }
             }
         }
     }
     if ($this->must_register && empty($this->posted['create_account'])) {
         jigoshop::add_error(__('Sorry, you must agree to creating an account', 'jigoshop'));
     }
     if ($this->must_register || empty($user_id) && $this->posted['create_account']) {
         if (!$this->show_signup) {
             jigoshop::add_error(__('Sorry, the shop owner has disabled guest purchases.', 'jigoshop'));
         }
         if (empty($this->posted['account_username'])) {
             jigoshop::add_error(__('Please enter an account username.', 'jigoshop'));
         }
         if (empty($this->posted['account_password'])) {
             jigoshop::add_error(__('Please enter an account password.', 'jigoshop'));
         }
         if ($this->posted['account_password_2'] !== $this->posted['account_password']) {
             jigoshop::add_error(__('Passwords do not match.', 'jigoshop'));
         }
         // Check the username
         if (!validate_username($this->posted['account_username'])) {
             jigoshop::add_error(__('Invalid email/username.', 'jigoshop'));
         } elseif (username_exists($this->posted['account_username'])) {
             jigoshop::add_error(__('An account is already registered with that username. Please choose another.', 'jigoshop'));
         }
         // Check the e-mail address
         if (email_exists($this->posted['billing_email'])) {
             jigoshop::add_error(__('An account is already registered with your email address. Please login.', 'jigoshop'));
         }
     }
     // Terms
     if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && jigoshop_get_page_id('terms') > 0) {
         jigoshop::add_error(__('You must accept our Terms &amp; Conditions.', 'jigoshop'));
     }
     if (jigoshop_cart::needs_shipping()) {
         // Shipping Method
         $available_methods = jigoshop_shipping::get_available_shipping_methods();
         if (!isset($available_methods[$this->posted['shipping_method']])) {
             jigoshop::add_error(__('Invalid shipping method.', 'jigoshop'));
         }
     }
 }
Ejemplo n.º 17
0
} elseif (is_tax('portfolio_tag')) {
    ?>
			<?php 
    echo theme_locals("portfolio_tag") . ": ";
    ?>
			<small><?php 
    echo single_tag_title('', false);
    ?>
 </small>
<!--Begin shop-->
		<?php 
} elseif ($shop_page) {
    if (class_exists('Woocommerce') && !is_single()) {
        $page_id = woocommerce_get_page_id('shop');
    } elseif (function_exists('jigoshop_init') && !is_singular()) {
        $page_id = jigoshop_get_page_id('shop');
    }
    echo get_page($page_id)->post_title;
    ?>
<!--End shop-->
		<?php 
} else {
    ?>
			<?php 
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            $pagetitle = get_post_custom_values("page-title");
            $pagedesc = get_post_custom_values("title-desc");
            if ($pagetitle == "") {
                the_title();
Ejemplo n.º 18
0
 function adjust_shop_page($q)
 {
     global $sitepress;
     if ($sitepress->get_default_language() != $sitepress->get_current_language()) {
         if (!empty($q->query_vars['pagename'])) {
             $shop_page = get_post(jigoshop_get_page_id('shop'));
             if ($shop_page->post_name == $q->query_vars['pagename']) {
                 unset($q->query_vars['page']);
                 unset($q->query_vars['pagename']);
                 $q->query_vars['post_type'] = 'product';
             }
         }
     }
 }
Ejemplo n.º 19
0
function jigoshop_download_product()
{
    if (isset($_GET['download_file']) && isset($_GET['order']) && isset($_GET['email'])) {
        global $wpdb;
        $download_file = (int) urldecode($_GET['download_file']);
        $order = urldecode($_GET['order']);
        $email = urldecode($_GET['email']);
        if (!is_email($email)) {
            wp_die(__('Invalid email address.', 'jigoshop') . ' <a href="' . home_url() . '">' . __('Go to homepage &rarr;', 'jigoshop') . '</a>');
        }
        $download_result = $wpdb->get_row($wpdb->prepare("\n\t\t\tSELECT downloads_remaining, user_id\n\t\t\tFROM " . $wpdb->prefix . "jigoshop_downloadable_product_permissions\n\t\t\tWHERE user_email = %s\n\t\t\tAND order_key = %s\n\t\t\tAND product_id = %s\n\t\t;", $email, $order, $download_file));
        if (!$download_result) {
            wp_die(__('Invalid downloads.', 'jigoshop') . ' <a href="' . home_url() . '">' . __('Go to homepage &rarr;', 'jigoshop') . '</a>');
            exit;
        }
        $order_id = isset($download_result->order_id) ? $download_result->order_id : false;
        $user_id = $download_result->user_id;
        $downloads_remaining = $download_result->downloads_remaining;
        if ($user_id && Jigoshop_Base::get_options()->get('jigoshop_downloads_require_login') == 'yes') {
            if (!is_user_logged_in()) {
                wp_die(__('You must be logged in to download files.', 'jigoshop') . ' <a href="' . wp_login_url(get_permalink(jigoshop_get_page_id('myaccount'))) . '">' . __('Login &rarr;', 'jigoshop') . '</a>');
                exit;
            } else {
                $current_user = wp_get_current_user();
                if ($user_id != $current_user->ID) {
                    wp_die(__('This is not your download link.', 'jigoshop'));
                    exit;
                }
            }
        }
        if ($order_id) {
            $order = new jigoshop_order($order_id);
            if ($order->status != 'completed' && $order->status != 'processing' && $order->status != 'publish') {
                wp_die(__('Invalid order.', 'jigoshop') . ' <a href="' . home_url() . '">' . __('Go to homepage &rarr;', 'jigoshop') . '</a>');
                exit;
            }
        }
        if ($downloads_remaining == '0') {
            wp_die(sprintf(__('Sorry, you have reached your download limit for this file. <a href="%s">Go to homepage &rarr;</a>', 'jigoshop'), home_url()));
        } else {
            if ($downloads_remaining > 0) {
                $wpdb->update($wpdb->prefix . "jigoshop_downloadable_product_permissions", array('downloads_remaining' => $downloads_remaining - 1), array('user_email' => $email, 'order_key' => $order, 'product_id' => $download_file), array('%d'), array('%s', '%s', '%d'));
            }
            $file_path = get_post_meta($download_file, 'file_path', true);
            if (!$file_path) {
                wp_die(sprintf(__('File not found. <a href="%s">Go to homepage &rarr;</a>', 'jigoshop'), home_url()));
            }
            // Get URLS with https
            $site_url = site_url();
            $network_url = network_admin_url();
            if (is_ssl()) {
                $site_url = str_replace('https:', 'http:', $site_url);
                $network_url = str_replace('https:', 'http:', $network_url);
            }
            if (!is_multisite()) {
                $file_path = str_replace(trailingslashit($site_url), ABSPATH, $file_path);
            } else {
                $upload_dir = wp_upload_dir();
                // Try to replace network url
                $file_path = str_replace(trailingslashit($network_url), ABSPATH, $file_path);
                // Now try to replace upload URL
                $file_path = str_replace($upload_dir['baseurl'], $upload_dir['basedir'], $file_path);
            }
            $file_path = apply_filters('jigoshop_download_file_path', $file_path, $download_file, $order, $email);
            // See if its local or remote
            if (strstr($file_path, 'http:') || strstr($file_path, 'https:') || strstr($file_path, 'ftp:')) {
                $remote_file = true;
            } else {
                $remote_file = false;
                $file_path = realpath($file_path);
            }
            // Download the file
            $file_extension = strtolower(substr(strrchr($file_path, "."), 1));
            switch ($file_extension) {
                case "pdf":
                    $ctype = "application/pdf";
                    break;
                case "exe":
                    $ctype = "application/octet-stream";
                    break;
                case "zip":
                    $ctype = "application/zip";
                    break;
                case "doc":
                    $ctype = "application/msword";
                    break;
                case "xls":
                    $ctype = "application/vnd.ms-excel";
                    break;
                case "ppt":
                    $ctype = "application/vnd.ms-powerpoint";
                    break;
                case "gif":
                    $ctype = "image/gif";
                    break;
                case "png":
                    $ctype = "image/png";
                    break;
                case "jpe":
                case "jpeg":
                case "jpg":
                    $ctype = "image/jpg";
                    break;
                default:
                    $ctype = "application/force-download";
            }
            do_action('jigoshop_before_download', $file_path, $order);
            @session_write_close();
            @set_time_limit(0);
            @set_magic_quotes_runtime(0);
            @ob_end_clean();
            if (ob_get_level()) {
                @ob_end_clean();
            }
            // required for IE, otherwise Content-Disposition may be ignored
            if (ini_get('zlib.output_compression')) {
                ini_set('zlib.output_compression', 'Off');
            }
            header("Pragma: no-cache");
            header("Expires: 0");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Robots: none");
            header("Content-Type: " . $ctype . "");
            header("Content-Description: File Transfer");
            header("Content-Transfer-Encoding: binary");
            if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
                // workaround for IE filename bug with multiple periods / multiple dots in filename
                $iefilename = preg_replace('/\\./', '%2e', basename($file_path), substr_count(basename($file_path), '.') - 1);
                header("Content-Disposition: attachment; filename=\"" . $iefilename . "\";");
            } else {
                header("Content-Disposition: attachment; filename=\"" . basename($file_path) . "\";");
            }
            header("Content-Length: " . @filesize($file_path));
            if ($remote_file) {
                header('Location: ' . $file_path);
            } else {
                @readfile("{$file_path}") or wp_die(sprintf(__('File not found. <a href="%s">Go to homepage &rarr;</a>', 'jigoshop'), home_url()));
            }
            exit;
        }
    }
}
Ejemplo n.º 20
0
 /**
  * Process the payment and return the result
  **/
 function process_payment($order_id)
 {
     $order = new jigoshop_order($order_id);
     $order->update_status('waiting-for-payment', __('Awaiting Bank Transfer', 'jigoshop'));
     jigoshop_cart::empty_cart();
     $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
     return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink($checkout_redirect))));
 }
Ejemplo n.º 21
0
    if (!$formatted_address) {
        _e('You have not set up a billing address yet.', 'jigoshop');
    } else {
        echo $formatted_address;
    }
    ?>
		</address>
	</div>
	<div class="col-2">
		<header class="title">
			<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');
Ejemplo n.º 22
0
 /**  Generates a URL so that a customer can checkout/pay for their (unpaid - pending) order via a link */
 public function get_checkout_payment_url()
 {
     $payment_page = apply_filters('jigoshop_get_checkout_payment_url', get_permalink(jigoshop_get_page_id('pay')));
     if (self::get_options()->get('jigoshop_force_ssl_checkout') == 'yes' || is_ssl()) {
         $payment_page = str_replace('http:', 'https:', $payment_page);
     }
     return add_query_arg('pay_for_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, $payment_page)));
 }
Ejemplo n.º 23
0
<?php

jigoshop::show_messages();
?>
<form action="<?php 
echo esc_url(apply_filters('jigoshop_get_change_password_page_id', get_permalink(jigoshop_get_page_id('change_password'))));
?>
" method="post">
	<p class="form-row form-row-first">
		<label for="password-1"><?php 
_e('New password', 'jigoshop');
?>
 <span class="required">*</span></label>
		<input type="password" class="input-text" name="password-1" id="password-1" />
	</p>

	<p class="form-row form-row-last">
		<label for="password-2"><?php 
_e('Re-enter new password', 'jigoshop');
?>
 <span class="required">*</span></label>
		<input type="password" class="input-text" name="password-2" id="password-2" />
	</p>

	<div class="clear"></div>
	<?php 
jigoshop::nonce_field('change_password');
?>
	<p><input type="submit" class="button" name="save_password" value="<?php 
_e('Save', 'jigoshop');
?>
Ejemplo n.º 24
0
function kopa_breadcrumb()
{
    if (is_main_query()) {
        global $post, $wp_query;
        $prefix = '&nbsp;/&nbsp;';
        $current_class = 'current-page';
        $description = '';
        $breadcrumb_before = '<div class="row-fluid"><div class="span12"><div class="breadcrumb">';
        $breadcrumb_after = '</div></div></div>';
        $breadcrumb_home = '<a href="' . esc_url(home_url()) . '">' . __('Home', kopa_get_domain()) . '</a>';
        $breadcrumb = '';
        ?>
        <?php 
        if (is_home()) {
            $breadcrumb .= $breadcrumb_home;
            $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, __('Blog', kopa_get_domain()));
        } else {
            if (is_post_type_archive('product') && jigoshop_get_page_id('shop')) {
                $breadcrumb .= $breadcrumb_home;
                $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, get_the_title(jigoshop_get_page_id('shop')));
            } else {
                if (is_tag()) {
                    $breadcrumb .= $breadcrumb_home;
                    $term = get_term(get_queried_object_id(), 'post_tag');
                    $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, $term->name);
                } else {
                    if (is_category()) {
                        $breadcrumb .= $breadcrumb_home;
                        $category_id = get_queried_object_id();
                        $terms_link = explode(',', substr(get_category_parents(get_queried_object_id(), TRUE, ','), 0, strlen(',') * -1));
                        $n = count($terms_link);
                        if ($n > 1) {
                            for ($i = 0; $i < $n - 1; $i++) {
                                $breadcrumb .= $prefix . $terms_link[$i];
                            }
                        }
                        $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, get_the_category_by_ID(get_queried_object_id()));
                    } else {
                        if (is_tax('product_cat')) {
                            $breadcrumb .= $breadcrumb_home;
                            $breadcrumb .= '<a href="' . get_page_link(jigoshop_get_page_id('shop')) . '">' . get_the_title(jigoshop_get_page_id('shop')) . '</a>';
                            $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'));
                                    $breadcrumb .= '<a href="' . get_term_link($item->slug, 'product_cat') . '">' . $item->name . '</a>';
                                }
                            }
                            $queried_object = get_queried_object();
                            $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, $queried_object->name);
                        } else {
                            if (is_tax('product_tag')) {
                                $breadcrumb .= $breadcrumb_home;
                                $breadcrumb .= '<a href="' . get_page_link(jigoshop_get_page_id('shop')) . '">' . get_the_title(jigoshop_get_page_id('shop')) . '</a>';
                                $queried_object = get_queried_object();
                                $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, $queried_object->name);
                            } else {
                                if (is_single()) {
                                    $breadcrumb .= $breadcrumb_home;
                                    if (get_post_type() === 'product') {
                                        $breadcrumb .= '<a href="' . get_page_link(jigoshop_get_page_id('shop')) . '">' . get_the_title(jigoshop_get_page_id('shop')) . '</a>';
                                        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');
                                                    $breadcrumb .= '<a href="' . get_term_link($item->slug, 'product_cat') . '">' . $item->name . '</a>';
                                                }
                                            }
                                            $breadcrumb .= '<a href="' . get_term_link($term->slug, 'product_cat') . '">' . $term->name . '</a>';
                                        }
                                        $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, get_the_title());
                                    } else {
                                        $categories = get_the_category(get_queried_object_id());
                                        if ($categories) {
                                            foreach ($categories as $category) {
                                                $breadcrumb .= $prefix . sprintf('<a href="%1$s">%2$s</a>', get_category_link($category->term_id), $category->name);
                                            }
                                        }
                                        $post_id = get_queried_object_id();
                                        $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, get_the_title($post_id));
                                    }
                                } else {
                                    if (is_page()) {
                                        if (!is_front_page()) {
                                            $post_id = get_queried_object_id();
                                            $breadcrumb .= $breadcrumb_home;
                                            $post_ancestors = get_post_ancestors($post);
                                            if ($post_ancestors) {
                                                $post_ancestors = array_reverse($post_ancestors);
                                                foreach ($post_ancestors as $crumb) {
                                                    $breadcrumb .= $prefix . sprintf('<a href="%1$s">%2$s</a>', get_permalink($crumb), get_the_title($crumb));
                                                }
                                            }
                                            $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, get_the_title(get_queried_object_id()));
                                        }
                                    } else {
                                        if (is_year() || is_month() || is_day()) {
                                            $breadcrumb .= $breadcrumb_home;
                                            $date = array('y' => NULL, 'm' => NULL, 'd' => NULL);
                                            $date['y'] = get_the_time('Y');
                                            $date['m'] = get_the_time('m');
                                            $date['d'] = get_the_time('j');
                                            if (is_year()) {
                                                $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, $date['y']);
                                            }
                                            if (is_month()) {
                                                $breadcrumb .= $prefix . sprintf('<a href="%1$s">%2$s</a>', get_year_link($date['y']), $date['y']);
                                                $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, date('F', mktime(0, 0, 0, $date['m'])));
                                            }
                                            if (is_day()) {
                                                $breadcrumb .= $prefix . sprintf('<a href="%1$s">%2$s</a>', get_year_link($date['y']), $date['y']);
                                                $breadcrumb .= $prefix . sprintf('<a href="%1$s">%2$s</a>', get_month_link($date['y'], $date['m']), date('F', mktime(0, 0, 0, $date['m'])));
                                                $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, $date['d']);
                                            }
                                        } else {
                                            if (is_search()) {
                                                $breadcrumb .= $breadcrumb_home;
                                                $s = get_search_query();
                                                $c = $wp_query->found_posts;
                                                $description = sprintf(__('<span class="%1$s">Your search for "%2$s"', kopa_get_domain()), $current_class, $s);
                                                $breadcrumb .= $prefix . $description;
                                            } else {
                                                if (is_author()) {
                                                    $breadcrumb .= $breadcrumb_home;
                                                    $author_id = get_queried_object_id();
                                                    $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</a>', $current_class, sprintf(__('Posts created by %1$s', kopa_get_domain()), get_the_author_meta('display_name', $author_id)));
                                                } else {
                                                    if (is_404()) {
                                                        $breadcrumb .= $breadcrumb_home;
                                                        $breadcrumb .= $prefix . sprintf('<span class="%1$s">%2$s</span>', $current_class, __('Page not found', kopa_get_domain()));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($breadcrumb) {
            echo apply_filters('kopa_breadcrumb', $breadcrumb_before . $breadcrumb . $breadcrumb_after);
        }
    }
}
Ejemplo n.º 25
0
/**
 * Properly sets the WP Nav Menus items classes for jigoshop queried objects
 *
 * @param $menu_items
 * @param array $args
 * @return
 * @TODO set parent items classes when the shop page is not at the nav menu root
 */
function jigoshop_nav_menu_items_classes($menu_items, $args)
{
    $options = Jigoshop_Base::get_options();
    $shop_page_id = (int) jigoshop_get_page_id('shop');
    // only add nav menu classes if the queried object is the Shop page or derivative (Product, Category, Tag)
    if (empty($shop_page_id) || !is_content_wrapped()) {
        return $menu_items;
    }
    $home_page_id = (int) $options->get('page_for_posts');
    foreach ((array) $menu_items as $key => $menu_item) {
        $classes = (array) $menu_item->classes;
        // unset classes set by WP on the home page item
        // shouldn't need a content wrap check as we can't get here without it  -JAP-
        if (is_content_wrapped() && $home_page_id == $menu_item->object_id) {
            $menu_items[$key]->current = false;
            unset($classes[array_search('current_page_parent', $classes)]);
            unset($classes[array_search('current-menu-item', $classes)]);
        }
        if (is_shop() && $shop_page_id == $menu_item->object_id) {
            // is products archive
            $menu_items[$key]->current = true;
            $classes[] = 'current-menu-item';
            $classes[] = 'current_page_item';
        } elseif ((is_product() || is_product_category() || is_product_tag()) && $shop_page_id == $menu_item->object_id) {
            // is another jigoshop object
            $classes[] = 'current_page_parent';
            $classes[] = 'current_menu_parent';
        }
        $menu_items[$key]->classes = array_unique($classes);
    }
    return $menu_items;
}
Ejemplo n.º 26
0
 /** gets the url to remove an item from the cart
  *
  * @param $cart_item_key
  * @return mixed|string|void
  */
 public static function get_remove_url($cart_item_key)
 {
     $cart_page_id = jigoshop_get_page_id('cart');
     if ($cart_page_id) {
         return apply_filters('jigoshop_get_remove_url', jigoshop::nonce_url('cart', add_query_arg('remove_item', $cart_item_key, get_permalink($cart_page_id))));
     }
     return '';
 }
Ejemplo n.º 27
0
jigoshop::nonce_field('process_checkout');
?>

			<?php 
do_action('jigoshop_review_order_before_submit');
?>

			<?php 
if (jigoshop_get_page_id('terms') > 0) {
    ?>
			<p class="form-row terms">
				<label for="terms" class="checkbox"><?php 
    _e('I accept the', 'jigoshop');
    ?>
 <a href="<?php 
    echo esc_url(get_permalink(jigoshop_get_page_id('terms')));
    ?>
" target="_blank"><?php 
    _e('terms &amp; conditions', 'jigoshop');
    ?>
</a></label>
				<input type="checkbox" class="input-checkbox" name="terms" <?php 
    if (isset($_POST['terms'])) {
        echo 'checked="checked"';
    }
    ?>
 id="terms" />
			</p>
			<?php 
}
?>
Ejemplo n.º 28
0
 /**
  * Process Response from WorldPay
  */
 private function process_response($posted)
 {
     $installation_id = $this->get_post('instId');
     $cartId = $this->get_post('cartId');
     $transId = $this->get_post('transId');
     $processed_transID = get_post_meta($cartId, '_worldpay_processed_transID', true);
     $amount = $this->get_post('amount');
     $authAmount = $this->get_post('authAmount');
     $authCurrency = $this->get_post('authCurrency');
     $currency = $this->get_post('currency');
     $shop_currency = Jigoshop_Base::get_options()->get('jigoshop_currency');
     $testMode = $this->get_post('testMode');
     $error = array();
     $order = new jigoshop_order((int) $cartId);
     // Do all checks only if transaction was processed.
     switch ($this->get_post('transStatus')) {
         case 'Y':
             // If the currency is locked.
             if ($this->fixed_currency == 'yes') {
                 // All currencies should be the same.
                 if ($currency != $authCurrency || $authCurrency != $shop_currency || $currency != $shop_currency) {
                     $error['Locked_Currency_Error'] = sprintf(__('The currency paid in was different than the one requested. Order #: %s. Currency paid in: %s, the amount paid: %s. You should investigate further.', 'jigoshop'), $order->id, $authCurrency, $authAmount);
                 }
                 // All amounts should be the same
                 if ($order->order_total != $amount || $authAmount != $order->order_total || $authAmount != $amount) {
                     $error['Locked_Amount_Error'] = sprintf(__('There were differences in the amounts received. Order #: %s. Submitted: %s, Paid: %s, Order Total: %s. You should investigate further.', 'jigoshop'), $order->id, $amount, $authAmount, $order->order_total);
                 }
             } else {
                 // If currency submitted to WorldPay is the same as your store one.
                 // They should always be the same even if you accept multiple currency payments.
                 if ($currency != $shop_currency) {
                     $error['currency'] = sprintf(__('The currency submitted to WorldPay (%s) is different than the main currency of your shop (%s). You should investigate further.', 'jigoshop'), $currency, $shop_currency);
                 }
                 // If multi-currency is supported, at least the amount submitted to WorldPay should be the same as the order total.
                 if ($order->order_total != $amount) {
                     $error['amount'] = sprintf(__('The order total (%s) is different than the amount submitted to WorldPay (%s). You should investigate further.', 'jigoshop'), $order->order_total, $amount);
                 }
             }
             // Check merchant.
             if ($installation_id != $this->installation_id) {
                 $error['instId'] = sprintf(__('Order was paid to installation ID: %s, which is different than the Installation ID set in your shop: %s. You should investigate further.', 'jigoshop'), $installation_id, $this->installation_id);
             }
             if ($transId == $processed_transID) {
                 $error['already_processed'] = sprintf(__('Payment with the same transaction ID (%s) was already processed for this order. You should investigate further.', 'jigoshop'), $transId);
             }
             if ($this->testmode == 'no' && $testMode > 0) {
                 $error['testmode'] = sprintf(__('Your shop is in Live mode, but you received a Test mode transaction. You should investigate further.', 'jigoshop'));
             }
             if (empty($error) && $testMode == 0) {
                 // Payment completed as live response
                 $order->add_order_note(__('WorldPay payment completed. Transaction ID: ' . $transId, 'jigoshop'));
                 update_post_meta($order->id, '_worldpay_processed_transID', $transId, $processed_transID);
                 $order->payment_complete();
                 $args = array('key' => $order->order_key, 'order' => $order->id);
                 $redirect_url = add_query_arg($args, get_permalink(jigoshop_get_page_id('thanks')));
             } elseif (empty($error) && $testMode > 0) {
                 // Payment completed as test response
                 $order->add_order_note(__('TESTMODE: WorldPay payment completed. Transaction ID: ' . $transId, 'jigoshop'));
                 update_post_meta($order->id, '_worldpay_processed_transID', $transId, $processed_transID);
                 $order->payment_complete();
                 $args = array('key' => $order->order_key, 'order' => $order->id);
                 $redirect_url = add_query_arg($args, get_permalink(jigoshop_get_page_id('thanks')));
             }
             if (!empty($error) && $this->receive_err_log == 'yes') {
                 $info = sprintf(__('Order #%s ', 'jigoshop'), $order->id);
                 $this->email_worldpay_error_logs($error, $posted, $info);
                 $redirect_url = get_permalink(jigoshop_get_page_id('checkout'));
             }
             break;
         case 'C':
             if ($testMode == 0) {
                 // Payment was canceled live.
                 $order->cancel_order(__('Order was canceled by customer at WorldPay.', 'jigoshop'));
             }
             if ($testMode > 0) {
                 // Payment was canceled in test mode.
                 $order->cancel_order(__('TESTMODE: Order was canceled by customer at WorldPay.', 'jigoshop'));
             }
             $redirect_url = $this->get_post('MC_cancel_return');
             break;
         default:
             // No action
             $redirect_url = $this->get_post('MC_cancel_return');
             break;
     }
     echo '<html><head><meta http-equiv="refresh" content="2;url=' . $redirect_url . '"></head><body><WPDISPLAY ITEM=banner></body></html>';
     exit;
 }
Ejemplo n.º 29
0
function jigoshop_pay_action()
{
    if (!is_jigoshop_single_page(JIGOSHOP_PAY)) {
        return;
    }
    if (isset($_GET['pay_for_order']) && isset($_GET['order']) && isset($_GET['order_id'])) {
        // Pay for existing order
        $order_key = urldecode($_GET['order']);
        $order_id = (int) $_GET['order_id'];
        $order = new jigoshop_order($order_id);
        if ($order->id == $order_id && $order->order_key == $order_key && $order->status == 'pending') {
            // Set customer location to order location
            if ($order->billing_country) {
                jigoshop_customer::set_country($order->billing_country);
            }
            if ($order->billing_state) {
                jigoshop_customer::set_state($order->billing_state);
            }
            if ($order->billing_postcode) {
                jigoshop_customer::set_postcode($order->billing_postcode);
            }
            // Pay form was posted - process payment
            if (isset($_POST['pay']) && jigoshop::verify_nonce('pay')) {
                // Update payment method
                if ($order->order_total > 0) {
                    $payment_method = jigowatt_clean($_POST['payment_method']);
                    $data = (array) maybe_unserialize(get_post_meta($order_id, 'order_data', true));
                    $data['payment_method'] = $payment_method;
                    update_post_meta($order_id, 'order_data', $data);
                    $available_gateways = jigoshop_payment_gateways::get_available_payment_gateways();
                    $result = $available_gateways[$payment_method]->process_payment($order_id);
                    // Redirect to success/confirmation/payment page
                    if ($result['result'] == 'success') {
                        wp_safe_redirect($result['redirect']);
                        exit;
                    }
                } else {
                    // No payment was required for order
                    $order->payment_complete();
                    // filter redirect page
                    $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
                    wp_safe_redirect(get_permalink($checkout_redirect));
                    exit;
                }
            }
        } elseif ($order->status != 'pending') {
            jigoshop::add_error(__('Your order has already been paid for. Please contact us if you need assistance.', 'jigoshop'));
        } else {
            jigoshop::add_error(__('Invalid order.', 'jigoshop'));
        }
    } else {
        // 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 || $order->status != 'pending') {
                wp_safe_redirect(apply_filters('jigoshop_get_myaccount_page_id', get_permalink(jigoshop_get_page_id('myaccount'))));
                exit;
            }
        } else {
            wp_safe_redirect(apply_filters('jigoshop_get_myaccount_page_id', get_permalink(jigoshop_get_page_id('myaccount'))));
            exit;
        }
    }
}
Ejemplo n.º 30
0
 public function get_success_url()
 {
     return add_query_arg(array('key' => $this->order->order_key, 'order' => $this->order->id), get_permalink(jigoshop_get_page_id('thanks')));
 }