/**
  * @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;
 }
Esempio n. 2
0
function jigoshop_checkout( $atts ) {

	if (!defined('JIGOSHOP_CHECKOUT')) define('JIGOSHOP_CHECKOUT', true);
	
	if (sizeof(jigoshop_cart::$cart_contents)==0) :
		wp_redirect(get_permalink(get_option('jigoshop_cart_page_id')));
		exit;
	endif;
	
	$non_js_checkout = (isset($_POST['update_totals']) && $_POST['update_totals']) ? true : false;
	
	$_checkout = jigoshop_checkout::instance();
	
	$_checkout->process_checkout();
	
	$result = jigoshop_cart::check_cart_item_stock();
	
	if (is_wp_error($result)) jigoshop::add_error( $result->get_error_message() );
	
	if ( jigoshop::error_count()==0 && $non_js_checkout) jigoshop::add_message( __('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'jigoshop') );
	
	jigoshop::show_messages();
	
	jigoshop_get_template('checkout/form.php', false);
	
}
 function receipt_page($order_id)
 {
     $this->init_paymentwall_configs();
     $order = new jigoshop_order($order_id);
     $widget = new Paymentwall_Widget($order->user_id == 0 ? $_SERVER['REMOTE_ADDR'] : $order->user_id, $this->widget, array(new Paymentwall_Product($order->id, $order->order_subtotal, $this->currency, 'Order #' . $order->id, Paymentwall_Product::TYPE_FIXED)), array_merge(array('email' => $order->billing_email, 'success_url' => $this->successurl, 'test_mode' => (int) $this->testmode == 'yes' ? 1 : 0, 'integration_module' => 'jigoshop'), $this->getUserProfileData($order)));
     echo $this->get_template('widget.html', array('iframe' => $widget->getHtmlCode(array('width' => '100%', 'height' => '400px')), 'thankyoutext' => __($this->thankyoutext, PW_JIGO_TEXT_DOMAIN)));
     jigoshop_cart::empty_cart();
 }
 public static function check_remove_coupon()
 {
     if (!empty($_GET['unset_coupon'])) {
         self::remove_coupon($_GET['unset_coupon']);
         jigoshop_session::instance()->chosen_shipping_method_id = null;
         jigoshop_cart::calculate_totals();
     }
 }
Esempio n. 5
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))));
 }
Esempio n. 6
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))));
 }
 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;
 }
 function receipt_paymentwall($order_id)
 {
     $this->paymentwall_init();
     $order = new jigoshop_order($order_id);
     $productNames = array();
     foreach ($order->items as $item) {
         array_push($productNames, $item['name']);
     }
     echo '<p>' . __($this->thankyoutext, 'jigoshop') . '</p>';
     $widget = new Paymentwall_Widget($order->user_id == 0 ? $_SERVER['REMOTE_ADDR'] : $order->user_id, $this->widget, array(new Paymentwall_Product($order->id, $order->order_subtotal, $this->currency, implode(', ', $productNames), Paymentwall_Product::TYPE_FIXED)), array('email' => $order->billing_email, 'integration_module' => 'jigoshop', 'success_url' => $this->successurl, 'test_mode' => (int) $this->testmode));
     echo $widget->getHtmlCode();
     jigoshop_cart::empty_cart();
 }
Esempio n. 9
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     if (is_cart()) {
         return;
     }
     extract($args);
     if (!empty($instance['title'])) {
         $title = $instance['title'];
     } else {
         $title = __('Cart', 'jigoshop');
     }
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo '<ul class="cart_list">';
     if (sizeof(jigoshop_cart::$cart_contents) > 0) {
         foreach (jigoshop_cart::$cart_contents as $item_id => $values) {
             $_product = $values['data'];
             if ($_product->exists() && $values['quantity'] > 0) {
                 echo '<li><a href="' . get_permalink($item_id) . '">';
                 if (has_post_thumbnail($item_id)) {
                     echo get_the_post_thumbnail($item_id, 'shop_tiny');
                 } else {
                     echo '<img src="' . jigoshop::plugin_url() . '/assets/images/placeholder.png" alt="Placeholder" width="' . jigoshop::get_var('shop_tiny_w') . '" height="' . jigoshop::get_var('shop_tiny_h') . '" />';
                 }
                 echo apply_filters('jigoshop_cart_widget_product_title', $_product->get_title(), $_product) . '</a> ' . $values['quantity'] . ' &times; ' . jigoshop_price($_product->get_price()) . '</li>';
             }
         }
     } else {
         echo '<li class="empty">' . __('No products in the cart.', 'jigoshop') . '</li>';
     }
     echo '</ul>';
     if (sizeof(jigoshop_cart::$cart_contents) > 0) {
         echo '<p class="total"><strong>';
         if (get_option('js_prices_include_tax') == 'yes') {
             _e('Total', 'jigoshop');
         } else {
             _e('Subtotal', 'jigoshop');
         }
         echo ':</strong> ' . jigoshop_cart::get_cart_total();
         echo '</p>';
         do_action('jigoshop_widget_shopping_cart_before_buttons');
         echo '<p class="buttons"><a href="' . jigoshop_cart::get_cart_url() . '" class="button">' . __('View Cart &rarr;', 'jigoshop') . '</a> <a href="' . jigoshop_cart::get_checkout_url() . '" class="button checkout">' . __('Checkout &rarr;', 'jigoshop') . '</a></p>';
     }
     echo $after_widget;
 }
Esempio n. 10
0
function jigoshop_cart($atts)
{
    unset(jigoshop_session::instance()->selected_rate_id);
    // Process Discount Codes
    if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && jigoshop::verify_nonce('cart')) {
        $coupon_code = sanitize_title($_POST['coupon_code']);
        jigoshop_cart::add_discount($coupon_code);
    } elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && jigoshop::verify_nonce('cart')) {
        // Update Shipping
        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();
        // chooses the method selected by user.
    }
    // Re-Calc prices. This needs to happen every time the cart page is loaded and after checking post results.
    jigoshop_cart::calculate_totals();
    $result = jigoshop_cart::check_cart_item_stock();
    if (is_wp_error($result)) {
        jigoshop::add_error($result->get_error_message());
    }
    jigoshop_render('shortcode/cart', array('cart' => jigoshop_cart::get_cart(), 'coupons' => jigoshop_cart::get_coupons()));
}
Esempio n. 11
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;
    }
}
 public static function get_available_shipping_methods()
 {
     $_available_methods = array();
     if (self::$enabled == 'yes') {
         foreach (self::get_all_methods() as $method) {
             /** @var $method jigoshop_shipping_method */
             if (jigoshop_cart::has_free_shipping_coupon() && $method->id == 'free_shipping') {
                 $_available_methods[$method->id] = $method;
             }
             if ($method->is_available() && $method->cost >= 0) {
                 $_available_methods[$method->id] = $method;
             }
         }
     }
     //throw error if there are no shipping methods
     if (empty($_available_methods)) {
         self::$shipping_error_message = __('Please enter your shipping destination and postal code to view shipping options and rates.', 'jigoshop');
         if (self::get_options()->get('jigoshop_enable_shipping_calc') == 'no' && is_cart()) {
             self::$shipping_error_message .= __(' If the Shipping Calculator is not available here, you will need to advance to the Checkout to do this.', 'jigoshop');
         }
         self::$shipping_error_message .= __(' There may be no methods available for your destination and you should contact us for assistance.', 'jigoshop');
     }
     return apply_filters('jigoshop_available_shipping_methods', $_available_methods);
 }
Esempio n. 13
0
function yiw_minicart()
{
    if (!class_exists('Jigoshop_Widget_Cart')) {
        return;
    }
    $cart = new Jigoshop_Widget_Cart();
    $args = array('before_title' => '<h3>', 'after_title' => '</h3>', 'before_widget' => '<div class="basketpopup">', 'after_widget' => '</div>');
    $instance = array('title' => __('My Cart', 'yiw'));
    // quantity
    $qty = 0;
    if (sizeof(jigoshop_cart::$cart_contents) > 0) {
        foreach (jigoshop_cart::$cart_contents as $item_id => $values) {
            $qty += $values['quantity'];
        }
    }
    if ($qty == 1) {
        $label = __('item', 'yiw');
    } else {
        $label = __('items', 'yiw');
    }
    echo '<a class="widget_shopping_cart trigger" href="' . jigoshop_cart::get_cart_url() . '">
			<span class="minicart"> ' . $qty . ' ' . $label . ' </span>
		</a>';
}
Esempio n. 14
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('on-hold', __('Awaiting cheque payment', 'jigoshop'));
		
		// Remove cart
		jigoshop_cart::empty_cart();
			
		// Return thankyou redirect
		return array(
			'result' 	=> 'success',
			'redirect'	=> add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('jigoshop_thanks_page_id'))))
		);
		
	}
Esempio n. 15
0
function jigoshop_cancel_order() {
	
	if ( isset($_GET['cancel_order']) && isset($_GET['order']) && isset($_GET['order_id']) ) :
		
		$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' && jigoshop::verify_nonce('cancel_order', '_GET')) :
			
			// Cancel the order + restore stock
			$order->cancel_order( __('Order cancelled by customer.', 'jigoshop') );
			
			// Message
			jigoshop::add_message( __('Your order was cancelled.', 'jigoshop') );
		
		elseif ($order->status!='pending') :
			
			jigoshop::add_error( __('Your order is no longer pending and could not be cancelled. Please contact us if you need assistance.', 'jigoshop') );
			
		else :
		
			jigoshop::add_error( __('Invalid order.', 'jigoshop') );
			
		endif;
		
		wp_safe_redirect(jigoshop_cart::get_cart_url());
		exit;
		
	endif;
}
Esempio n. 16
0
 function st_header_extras()
 {
     $extras = "<div class=\"header_extras\">";
     $extras .= '<a href="' . jigoshop_cart::get_cart_url() . '" class="minicart">';
     $extras .= '<span>';
     $extras .= jigoshop_cart::$cart_contents_count . ' items';
     $extras .= '</span>';
     $extras .= jigoshop_cart::get_cart_total();
     $extras .= '</a>';
     $extras .= "</div>";
     echo apply_filters('child_header_extras', $extras);
 }
Esempio n. 17
0
    function jbst_cart_dropdown()
    {
        global $current_user;
        get_currentuserinfo();
        global $jigoshop;
        ?>
			  <div class="btn-group pull-right" id="nav-cart-dropdown">
			    <a class="btn dropdown-toggle <?php 
        jbst_nav_shop_button_class();
        ?>
" data-toggle="dropdown" href="#">
			      <i class="glyphicon glyphicon-shopping-cart"></i> <span class="cart-contents"><?php 
        echo sprintf(_n('%d item &ndash; ', '%d items &ndash; ', jigoshop_cart::$cart_contents_count, 'jigoshop'), jigoshop_cart::$cart_contents_count) . jigoshop_cart::get_cart_total();
        ?>
</span>
			      <span class="caret"></span>
			    </a>
			    <ul class="dropdown-menu">
			      <li><a href="<?php 
        echo jigoshop_cart::get_cart_url();
        ?>
">View Cart</a></li>
			      <li class="divider"></li>
			      <li><a href="<?php 
        echo jigoshop_cart::get_checkout_url();
        ?>
">Checkout</a></li>
			    </ul>
			  </div>
			<?php 
    }
Esempio n. 18
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>';
}
Esempio n. 19
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)
 {
     // Hide widget if page is the cart or checkout
     if (is_cart() || is_checkout()) {
         return false;
     }
     extract($args);
     // Set the widget title
     $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Cart', 'jigoshop'), $instance, $this->id_base);
     // Print the widget wrapper & title
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     // Get the contents of the cart
     $cart_contents = jigoshop_cart::$cart_contents;
     // If there are items in the cart print out a list of products
     if (!empty($cart_contents)) {
         // Open the list
         echo '<ul class="cart_list">';
         foreach ($cart_contents as $key => $value) {
             // Get product instance
             $_product = $value['data'];
             if ($_product->exists() && $value['quantity'] > 0) {
                 echo '<li>';
                 // Print the product image & title with a link to the permalink
                 echo '<a href="' . esc_attr(get_permalink($_product->id)) . '" title="' . esc_attr($_product->get_title()) . '">';
                 // Print the product thumbnail image if exists else display placeholder
                 echo has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : jigoshop_get_image_placeholder('shop_tiny');
                 // Print the product title
                 echo '<span class="js_widget_product_title">' . $_product->get_title() . '</span>';
                 echo '</a>';
                 // Displays variations and cart item meta
                 echo jigoshop_cart::get_item_data($value);
                 // Print the quantity & price per product
                 echo '<span class="js_widget_product_price">' . $value['quantity'] . ' &times; ' . $_product->get_price_html() . '</span>';
                 echo '</li>';
             }
         }
         echo '</ul>';
         // Close the list
         // Print the cart total
         echo '<p class="total"><strong>';
         echo __('Subtotal', 'jigoshop');
         echo ':</strong> ' . jigoshop_price($this->total_cart_items());
         echo '</p>';
         do_action('jigoshop_widget_cart_before_buttons');
         // Print view cart & checkout buttons
         $view_cart_button_label = isset($instance['view_cart_button']) ? $instance['view_cart_button'] : __('View Cart &rarr;', 'jigoshop');
         $checkout_button_label = isset($instance['checkout_button']) ? $instance['checkout_button'] : __('Checkout &rarr;', 'jigoshop');
         echo '<p class="buttons">';
         echo '<a href="' . esc_attr(jigoshop_cart::get_cart_url()) . '" class="button">' . __($view_cart_button_label, 'jigoshop') . '</a>';
         echo '<a href="' . esc_attr(jigoshop_cart::get_checkout_url()) . '" class="button checkout">' . __($checkout_button_label, 'jigoshop') . '</a>';
         echo '</p>';
     } else {
         echo '<span class="empty">' . __('No products in the cart.', 'jigoshop') . '</span>';
     }
     // Print closing widget wrapper
     echo $after_widget;
 }
 function receipt_kaznachey($order_id)
 {
     $this->kaznachey_init();
     $order = new jigoshop_order($order_id);
     $sum = $qty = 0;
     foreach ($order->items as $item) {
         $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($item['id']), 'large');
         $request['Products'][] = array("ProductId" => $item['id'], "ProductName" => $item['name'], "ProductPrice" => $item['cost'], "ProductItemsNum" => $item['qty'], "ImageUrl" => isset($thumb[0]) ? $thumb[0] : '');
         $sum += $item['cost'] * $item['qty'];
         $qty += $item['qty'];
     }
     // Доставка
     if (jigoshop_shipping::is_enabled()) {
         if ($order->order_shipping > 0) {
             $request['Products'][] = array("ProductId" => 1, "ProductName" => 'Доставка', "ProductPrice" => $order->order_shipping, "ProductItemsNum" => 1, "ImageUrl" => '');
             $sum += $order->order_shipping;
             $qty += 1;
         }
     }
     $request["MerchantGuid"] = $this->merchantGuid;
     $request['SelectedPaySystemId'] = $_COOKIE['cc_types'] ? $_COOKIE['cc_types'] : $this->GetMerchnatInfo(false, true);
     $request['Currency'] = $this->currency;
     $request['Language'] = $this->language;
     $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
     $request['PaymentDetails'] = array("EMail" => $order->billing_email, "PhoneNumber" => $order->billing_phone, "MerchantInternalPaymentId" => $order->id, "MerchantInternalUserId" => $order->user_id, "StatusUrl" => add_query_arg('key', $order->order_key, add_query_arg('order', $order->id, get_permalink($checkout_redirect))), "ReturnUrl" => get_permalink($checkout_redirect), "CustomMerchantInfo" => "", "BuyerCountry" => $order->billing_country, "BuyerFirstname" => $order->billing_first_name, "BuyerPatronymic" => '', "BuyerLastname" => $order->billing_last_name, "BuyerStreet" => $order->billing_address_1, "BuyerZone" => $order->billing_state, "BuyerZip" => '', "BuyerCity" => $order->billing_city, "DeliveryFirstname" => $order->shipping_first_name, "DeliveryPatronymic" => '', "DeliveryLastname" => $order->shipping_last_name, "DeliveryZip" => '', "DeliveryCountry" => $order->shipping_country, "DeliveryStreet" => $order->shipping_address_1, "DeliveryCity" => $order->shipping_city, "DeliveryZone" => $order->shipping_state);
     $request["Signature"] = md5(strtoupper($this->merchantGuid) . number_format($sum, 2, ".", "") . $request["SelectedPaySystemId"] . $request["PaymentDetails"]["EMail"] . $request["PaymentDetails"]["PhoneNumber"] . $request["PaymentDetails"]["MerchantInternalUserId"] . $request["PaymentDetails"]["MerchantInternalPaymentId"] . strtoupper($request["Language"]) . strtoupper($request["Currency"]) . strtoupper($this->merchnatSecretKey));
     $response = $this->sendRequestKaznachey(json_encode($request), "CreatePaymentEx");
     $result = json_decode($response, true);
     if ($result['ErrorCode'] != 0) {
         wp_redirect(home_url());
         exit;
     }
     echo base64_decode($result["ExternalForm"]);
     jigoshop_cart::empty_cart();
     exit;
 }
 * versions in the future. If you wish to customise Jigoshop core for your needs,
 * please use our GitHub repository to publish essential changes for consideration.
 *
 * @package             Jigoshop
 * @category            Checkout
 * @author              Jigoshop
 * @copyright           Copyright © 2011-2014 Jigoshop.
 * @license             GNU General Public License v3
 */
?>


<?php 
do_action('before_checkout_form');
// filter hook for include new pages inside the payment method
$get_checkout_url = apply_filters('jigoshop_get_checkout_url', jigoshop_cart::get_checkout_url());
?>

<form name="checkout" method="post" class="checkout" action="<?php 
echo esc_url($get_checkout_url);
?>
">

	<h3 id="order_review_heading"><?php 
_e('Your Order', 'jigoshop');
?>
</h3>

	<?php 
do_action('jigoshop_checkout_order_review');
?>
Esempio n. 22
0
            echo '
							<tr>
								<td>' . $_product->get_title() . '</td>
								<td>' . $values['quantity'] . '</td>
								<td>' . jigoshop_price($_product->get_price_excluding_tax() * $values['quantity'], array('ex_tax_label' => 1)) . '</td>
							</tr>';
        }
    }
}
?>
		</tbody>
	</table>
	
	<div id="payment">
		<?php 
if (jigoshop_cart::needs_payment()) {
    ?>
		<ul class="payment_methods methods">
			<?php 
    $available_gateways = jigoshop_payment_gateways::get_available_payment_gateways();
    if ($available_gateways) {
        // Chosen Method
        if (sizeof($available_gateways)) {
            current($available_gateways)->set_current();
        }
        foreach ($available_gateways as $gateway) {
            ?>
						<li>
						<input type="radio" id="payment_method_<?php 
            echo $gateway->id;
            ?>
 public function add_cart_conversion_prices()
 {
     $currencies_to_convert = $this->getCurrenciesToConvert();
     if ($currencies_to_convert) {
         $priceHtML .= $this->getRenderHeader();
         $priceHtML .= '<ul class="price-conversions">';
         foreach ($currencies_to_convert as $cc) {
             if (get_option($this->data['prefix'] . 'design') == 1) {
                 $priceHtML .= '<li><img src="' . str_replace("/classes", "", $this->plugin_url) . 'assets/images/flags/' . strtolower($cc) . '.png" alt="' . $cc . '"/> ' . $this->convert(jigoshop_cart::get_total(), $cc) . '</li>';
             } else {
                 $priceHtML .= '<li>' . $cc . '(' . $this->get_currency_symbol($cc) . ') ' . $this->convert(jigoshop_cart::get_total(), $cc) . '</li>';
             }
         }
         $priceHtML .= '</ul>';
         return '<div class="currency-conversion">' . $priceHtML . '</div>';
     }
 }
Esempio n. 24
0
if ($include_files) :
	foreach($include_files as $filename) :
		if (!empty($filename) && strstr($filename, 'php')) :
			include_once($filename);
		endif;
	endforeach;
endif;
			
$jigoshop 					= jigoshop::get();
		
// Init class singletons
$jigoshop_customer 			= jigoshop_customer::get();				// Customer class, sorts out session data such as location
$jigoshop_shipping 			= jigoshop_shipping::get();				// Shipping class. loads and stores shipping methods
$jigoshop_payment_gateways 	= jigoshop_payment_gateways::get();		// Payment gateways class. loads and stores payment methods
$jigoshop_cart 				= jigoshop_cart::get();					// Cart class, stores the cart contents
		
// Constants
if (!defined('JIGOSHOP_USE_CSS')) :
	if (get_option('jigoshop_disable_css')=='yes') define('JIGOSHOP_USE_CSS', false);
	else define('JIGOSHOP_USE_CSS', true);
endif;
if (!defined('JIGOSHOP_TEMPLATE_URL')) define('JIGOSHOP_TEMPLATE_URL', 'jigoshop/'); // Trailing slash is important :)
		
/**
 * Add post thumbnail support to wordpress
 **/
add_theme_support( 'post-thumbnails' );
	
/**
 * Filters and hooks
 /**
  * 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'));
         }
     }
 }
Esempio n. 26
0
function jigoshop_init()
{
    // Override default translations with custom .mo's found in wp-content/languages/jigoshop first.
    load_textdomain('jigoshop', WP_LANG_DIR . '/jigoshop/jigoshop-' . get_locale() . '.mo');
    load_plugin_textdomain('jigoshop', false, dirname(plugin_basename(__FILE__)) . '/languages/');
    add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'jigoshop_admin_bar_links');
    do_action('before_jigoshop_init');
    // instantiate options -after- loading text domains
    $options = Jigoshop_Base::get_options();
    jigoshop_post_type();
    // register taxonomies
    new jigoshop_cron();
    // -after- text domains and Options instantiation allows settings translations
    jigoshop_set_image_sizes();
    // called -after- our Options are loaded
    // add Singletons here so that the taxonomies are loaded before calling them.
    jigoshop_session::instance();
    // Start sessions if they aren't already
    jigoshop::instance();
    // Utility functions, uses sessions
    jigoshop_customer::instance();
    // Customer class, sorts session data such as location
    // Jigoshop will instantiate gateways and shipping methods on this same 'init' action hook
    // with a very low priority to ensure text domains are loaded first prior to installing any external options
    jigoshop_shipping::instance();
    // Shipping class. loads shipping methods
    jigoshop_payment_gateways::instance();
    // Payment gateways class. loads payment methods
    jigoshop_cart::instance();
    // Cart class, uses sessions
    add_filter('mce_external_plugins', 'jigoshop_register_shortcode_editor');
    add_filter('mce_buttons', 'jigoshop_register_shortcode_buttons');
    if (!is_admin()) {
        /* Catalog Filters */
        add_filter('loop-shop-query', create_function('', 'return array("orderby" => "' . $options->get('jigoshop_catalog_sort_orderby') . '","order" => "' . $options->get('jigoshop_catalog_sort_direction') . '");'));
        add_filter('loop_shop_columns', create_function('', 'return ' . $options->get('jigoshop_catalog_columns') . ';'));
        add_filter('loop_shop_per_page', create_function('', 'return ' . $options->get('jigoshop_catalog_per_page') . ';'));
        jigoshop_catalog_query::instance();
        // front end queries class
        jigoshop_request_api::instance();
        // front end request api for URL's
    }
    jigoshop_roles_init();
    do_action('jigoshop_initialize_plugins');
}
Esempio n. 27
0
					if ($_product->exists() && $values['quantity']>0) :
						echo '
							<tr>
								<td>'.$_product->get_title().'</td>
								<td>'.$values['quantity'].'</td>
								<td>'.jigoshop_price($_product->get_price_excluding_tax()*$values['quantity'], array('ex_tax_label' => 1)).'</td>
							</tr>';
					endif;
				endforeach; 
			endif;
			?>
		</tbody>
	</table>
	
	<div id="payment">
		<?php if (jigoshop_cart::needs_payment()) : ?>
		<ul class="payment_methods methods">
			<?php 
				$available_gateways = jigoshop_payment_gateways::get_available_payment_gateways();
				if ($available_gateways) : 
					// Chosen Method
					if (sizeof($available_gateways)) current($available_gateways)->set_current();
					foreach ($available_gateways as $gateway ) :
						?>
						<li>
						<input type="radio" id="payment_method_<?php echo $gateway->id; ?>" class="input-radio" name="payment_method" value="<?php echo $gateway->id; ?>" <?php if ($gateway->chosen) echo 'checked="checked"'; ?> />
						<label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->title; ?> <?php echo apply_filters('gateway_icon', $gateway->icon(), $gateway->id); ?></label> 
							<?php
								if ($gateway->has_fields || $gateway->description) : 
									echo '<div class="payment_box payment_method_'.$gateway->id.'" style="display:none;">';
									$gateway->payment_fields();
Esempio n. 28
0
</td>
					<td>
						<?php 
        echo jigoshop_price($product->get_defined_price() * $values['quantity'], array('ex_tax_label' => Jigoshop_Base::get_options()->get('jigoshop_show_prices_with_tax') == 'yes' ? 2 : 1));
        ?>
					</td>
				</tr>
			<?php 
    }
}
?>
		</tbody>
	</table>

	<?php 
$coupons = jigoshop_cart::get_coupons();
?>
	<table>
		<tr>
			<td colspan="6" class="actions">
				<?php 
if (JS_Coupons::has_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');
    ?>
 public function get_cart_url()
 {
     $cart_url = jigoshop_cart::get_cart_url();
     return $cart_url;
 }
Esempio n. 30
0
	/** clears the cart/coupon data and re-calcs totals */
	function clear_cache() {
		self::$cart_contents = array();
		self::$applied_coupons = array();
		unset( $_SESSION['cart'] );
		unset( $_SESSION['coupons'] );
		self::calculate_totals();
	}