/**
     * Echos the current store navigation links.
     *
     * @param bool $echo Optional, whether to echo. Defaults to true
     */
    function mp_store_navigation($echo = true)
    {
        global $mp;
        //navigation
        if (!$mp->get_setting('disable_cart')) {
            $nav = '<ul class="mp_store_navigation"><li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>';
            $nav .= '<li class="page_item"><a href="' . mp_cart_link(false, true) . '" title="' . __('Shopping Cart', 'mp') . '">' . __('Shopping Cart', 'mp') . '</a></li>';
            $nav .= '<li class="page_item"><a href="' . mp_orderstatus_link(false, true) . '" title="' . __('Order Status', 'mp') . '">' . __('Order Status', 'mp') . '</a></li>
</ul>';
        } else {
            $nav = '<ul class="mp_store_navigation">
<li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>
</ul>';
        }
        $nav = apply_filters('mp_store_navigation', $nav);
        if ($echo) {
            echo $nav;
        } else {
            return $nav;
        }
    }
 /**
  * Returns the current shopping cart link.
  * @param bool url Optional, whether to return a link or url. Defaults to show link.
  * @param string link_text Optional, text to show in link.
  */
 function mp_cart_link_sc($atts)
 {
     extract(shortcode_atts(array('url' => false, 'link_text' => ''), $atts));
     return mp_cart_link(false, $url, $link_text);
 }
 /**
  * Use this to do the final payment. Create the order then process the payment. If
  *  you know the payment is successful right away go ahead and change the order status
  *  as well.
  *  Call $mp->cart_checkout_error($msg, $context); to handle errors. If no errors
  *  it will redirect to the next step.
  *
  * @param array $cart. Contains the cart contents for the current blog, global cart if $mp->global_cart is true
  * @param array $shipping_info. Contains shipping info and email in case you need it
  */
 function process_payment($cart, $shipping_info)
 {
     global $mp, $current_user;
     $timestamp = time();
     $settings = get_option('mp_settings');
     $url = $this->API_URL . "api/checkout/v2/merchantCheckoutForm/Merchant/" . $this->API_Merchant_id;
     $order_id = $mp->generate_order_id();
     $params = array();
     $params['_type'] = 'checkout-shopping-cart';
     $params['shopping-cart.merchant-private-data'] = $order_id;
     $params['checkout-flow-support.merchant-checkout-flow-support.edit-cart-url'] = mp_cart_link(false, true);
     $params["checkout-flow-support.merchant-checkout-flow-support.continue-shopping-url"] = mp_store_link(false, true);
     $params["checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.tax-rules.default-tax-rule-1.shipping-taxed"] = $settings['tax']['tax_shipping'] ? 'true' : 'false';
     $params["checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.tax-rules.default-tax-rule-1.tax-areas.world-area-1"] = '';
     $totals = array();
     $item_params = array();
     $i = 1;
     $items = 0;
     $coupon_code = $mp->get_coupon_code();
     foreach ($cart as $product_id => $variations) {
         foreach ($variations as $data) {
             $price = $mp->coupon_value_product($coupon_code, $data['price'] * $data['quantity'], $product_id);
             $totals[] = $price;
             $item_params["shopping-cart.items.item-{$i}.item-name"] = $data['name'];
             $item_params["shopping-cart.items.item-{$i}.item-description"] = $data['url'];
             $item_params["shopping-cart.items.item-{$i}.unit-price"] = $price;
             $item_params["shopping-cart.items.item-{$i}.unit-price.currency"] = $this->currencyCode;
             $item_params["shopping-cart.items.item-{$i}.quantity"] = $data['quantity'];
             $item_params["shopping-cart.items.item-{$i}.merchant-item-id"] = $data['SKU'];
             $i++;
             $items++;
         }
     }
     $total = array_sum($totals);
     $params = array_merge($params, $item_params);
     //shipping line
     $shipping_tax = 0;
     if (($shipping_price = $mp->shipping_price(false)) !== false) {
         $total += $shipping_price;
         $shipping_tax = $mp->shipping_tax_price($shipping_price) - $shipping_price;
         $params["checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-1.price"] = $shipping_price;
         $params["checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-1.price.currency"] = $this->currencyCode;
         $params["checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-1.name"] = __('Standard Shipping', 'mp');
     }
     //tax line if tax inclusive pricing is off. It it's on it would screw up the totals
     if (!$mp->get_setting('tax->tax_inclusive')) {
         $tax_price = $mp->tax_price(false) + $shipping_tax;
         $total += $tax_price;
         $params["checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.tax-rules.default-tax-rule-1.rate"] = $tax_price;
     } else {
         $params["checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.tax-rules.default-tax-rule-1.rate"] = '0.00';
     }
     $param_list = array();
     foreach ($params as $k => $v) {
         $param_list[] = "{$k}=" . rawurlencode($v);
     }
     $param_str = implode('&', $param_list);
     //setup transients for ipn in case checkout doesn't redirect (ipn should come within 12 hrs!)
     set_transient('mp_order_' . $order_id . '_cart', $cart, 60 * 60 * 12);
     set_transient('mp_order_' . $order_id . '_shipping', $shipping_info, 60 * 60 * 12);
     set_transient('mp_order_' . $order_id . '_userid', $current_user->ID, 60 * 60 * 12);
     $response = $this->google_api_request($param_str, $url);
     if ($response['_type'] == 'checkout-redirect') {
         wp_redirect($response['redirect-url']);
         exit;
     } else {
         $mp->cart_checkout_error(sprintf(__('There was a problem setting up your purchase with Google Checkout. Please try again or <a href="%s">select a different payment method</a>.<br/>%s', 'mp'), mp_checkout_step_url('checkout'), @$response['error-message']));
     }
 }
    private function _add_footer_script()
    {
        $href = esc_url(mp_cart_link(false, true));
        $message = esc_js(__('Please, proceed to checkout.', 'appointments'));
        $js = <<<EO_MP_JS
;(function (\$) {
\t\$(document).on('app-confirmation-response_received', function (e, response) {
\t\tif (response && response.mp && 1 == response.mp) {
\t\t\t\$(".appointments-confirmation-wrapper").replaceWith('<p class="app-confirmation-marketpress"><a href="{$href}">{$message}</a></p>');
\t\t}
\t});
})(jQuery);
EO_MP_JS;
        $this->_core->add2footer($js);
    }
Beispiel #5
0
 function filter_nav_menu($list, $args = array())
 {
     $store_object = false;
     if ($args->depth == 1) {
         return $list;
     }
     //find store page
     $store_url = mp_store_link(false, true);
     $store_page = get_option('mp_store_page');
     foreach ($list as $menu_item) {
         if ($menu_item->object_id == $store_page || $menu_item->url == $store_url) {
             $store_object = $menu_item;
             break;
         }
     }
     if ($store_object) {
         $obj_products = clone $store_object;
         $obj_products->title = __('Products', 'mp');
         $obj_products->menu_item_parent = $store_object->ID;
         $obj_products->ID = '99999999999';
         $obj_products->db_id = '99999999999';
         $obj_products->post_name = '99999999999';
         $obj_products->url = mp_products_link(false, true);
         $obj_products->current = get_query_var('pagename') == 'product_list' ? true : false;
         $obj_products->current_item_ancestor = get_query_var('pagename') == 'product_list' ? true : false;
         $list[] = $obj_products;
         //if cart disabled return only the products menu item
         if ($this->get_setting('disable_cart')) {
             return $list;
         }
         $obj_cart = clone $store_object;
         $obj_cart->title = __('Shopping Cart', 'mp');
         $obj_cart->menu_item_parent = $store_object->ID;
         $obj_cart->ID = '99999999999';
         $obj_cart->db_id = '99999999999';
         $obj_cart->post_name = '99999999999';
         $obj_cart->url = mp_cart_link(false, true);
         $obj_cart->current = get_query_var('pagename') == 'cart' ? true : false;
         $obj_cart->current_item_ancestor = get_query_var('pagename') == 'cart' ? true : false;
         $list[] = $obj_cart;
         $obj_order = clone $store_object;
         $obj_order->title = __('Order Status', 'mp');
         $obj_order->menu_item_parent = $store_object->ID;
         $obj_order->ID = '99999999999';
         $obj_order->db_id = '99999999999';
         $obj_order->post_name = '99999999999';
         $obj_order->url = mp_orderstatus_link(false, true);
         $obj_order->current = get_query_var('pagename') == 'orderstatus' ? true : false;
         $obj_order->current_item_ancestor = get_query_var('pagename') == 'orderstatus' ? true : false;
         $list[] = $obj_order;
     }
     return $list;
 }
Beispiel #6
0
/**
 * Echos the current store navigation links.
 *
 * @param bool $echo Optional, whether to echo. Defaults to true
 */
function mp_store_navigation($echo = true)
{
    $settings = get_option('mp_settings');
    //navigation
    if (!$settings['disable_cart']) {
        $nav = '<ul class="mp_store_navigation"><li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>';
        $nav .= '<li class="page_item"><a href="' . mp_cart_link(false, true) . '" title="' . __('Shopping Cart', 'mp') . '">' . __('Shopping Cart', 'mp') . '</a></li>';
        $nav .= '<li class="page_item"><a href="' . mp_orderstatus_link(false, true) . '" title="' . __('Order Status', 'mp') . '">' . __('Order Status', 'mp') . '</a></li>
</ul>';
    } else {
        $nav = '<ul class="mp_store_navigation">
<li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>
</ul>';
    }
    if ($echo) {
        echo $nav;
    } else {
        return $nav;
    }
}
 function process_event_payment_forms($form, $event_id)
 {
     if (!$this->_is_mp_present()) {
         return $form;
     }
     return '<p><a href="' . esc_url(mp_cart_link(false, true)) . '">' . __('Click here to purchase your ticket', Eab_EventsHub::TEXT_DOMAIN) . '</a></p>';
 }
Beispiel #8
0
/**
 * Echos the current shopping cart contents. Use in the cart template.
 *
 * @param string $context Optional. Possible values: widget, checkout
 * @param string $checkoutstep Optional. Possible values: checkout-edit, shipping, checkout, confirm-checkout, confirmation
 * @param bool $echo Optional. default true
 */
function flexmarket_show_cart($context = '', $checkoutstep = null, $echo = true, $btnclass = '')
{
    global $mp, $blog_id;
    $content = '';
    if ($checkoutstep == null) {
        $checkoutstep = get_query_var('checkoutstep');
    }
    if (mp_items_in_cart() || $checkoutstep == 'confirmation') {
        // type = widget
        if ($context == 'widget') {
            $content .= _flexmarket_cart_table('widget', false, $btnclass);
            $content .= '<div class="mp_cart_actions_widget">';
            $content .= '<a class="mp_empty_cart" href="' . mp_cart_link(false, true) . '?empty-cart=1" title="' . __('Empty your shopping cart', 'flexmarket') . '">' . __('Empty Cart', 'flexmarket') . '</a>';
            $content .= '<a class="mp_checkout_link" href="' . mp_cart_link(false, true) . '" title="' . __('Go To Checkout Page', 'flexmarket') . '">' . __('Checkout &raquo;', 'flexmarket') . '</a>';
            $content .= '<div class="clear"></div>';
            $content .= '</div>';
        } else {
            if ($context == 'checkout') {
                //generic error message context for plugins to hook into
                $content .= apply_filters('mp_checkout_error_checkout', '');
                if ($mp->get_setting('show_purchase_breadcrumbs') == 1) {
                    $content .= flexmarket_cart_breadcrumbs($checkoutstep);
                }
                //handle checkout steps
                switch ($checkoutstep) {
                    case 'shipping':
                        $content .= do_shortcode($mp->get_setting('msg->shipping'));
                        $content .= _flexmarket_cart_shipping(true, false, $btnclass);
                        break;
                    case 'checkout':
                        $content .= do_shortcode($mp->get_setting('msg->checkout'));
                        $content .= _flexmarket_cart_payment('form', false, $btnclass);
                        break;
                    case 'confirm-checkout':
                        $content .= do_shortcode($mp->get_setting('msg->confirm_checkout'));
                        $content .= _flexmarket_cart_table('checkout', false, $btnclass);
                        $content .= _flexmarket_cart_shipping(false, false, $btnclass);
                        $content .= _flexmarket_cart_payment('confirm', false, $btnclass);
                        break;
                    case 'confirmation':
                        $content .= do_shortcode($mp->get_setting('msg->success'));
                        $content .= _flexmarket_cart_payment('confirmation', false, $btnclass);
                        break;
                    default:
                        $content .= do_shortcode($mp->get_setting('msg->cart'));
                        $content .= _flexmarket_cart_table('checkout-edit', false, $btnclass);
                        $content .= '<div class="clear padding20"></div>';
                        $content .= _flexmarket_cart_login(false, $btnclass);
                        break;
                }
            } else {
                $content .= _flexmarket_cart_table('checkout', false, $btnclass);
                $content .= '<div class="mp_cart_actions">';
                $content .= '<a class="mp_empty_cart btn' . $btnclass . '" href="' . mp_cart_link(false, true) . '?empty-cart=1" title="' . __('Empty your shopping cart', 'flexmarket') . '">' . __('Empty Cart', 'flexmarket') . '</a>';
                $content .= '<a class="mp_checkout_link btn' . $btnclass . '" href="' . mp_cart_link(false, true) . '" title="' . __('Go To Checkout Page', 'flexmarket') . '">' . __('Checkout &raquo;', 'flexmarket') . '</a>';
                $content .= '</div>';
            }
        }
    } else {
        if ($context != 'widget') {
            $content .= do_shortcode($mp->get_setting('msg->cart'));
        }
        $content .= '<div class="mp_cart_empty"><p>' . __('There are no items in your cart.', 'flexmarket') . '</p></div>';
        $content .= '<div id="mp_cart_actions_widget"><a class="mp_store_link btn' . $btnclass . '" href="' . mp_products_link(false, true) . '">' . __('Browse Products &raquo;', 'flexmarket') . '</a></div>';
    }
    if ($echo) {
        echo $content;
    } else {
        return $content;
    }
}
Beispiel #9
0
    function filter_list_pages($list, $args)
    {
        if ($args['depth'] == 1) {
            return $list;
        }
        $temp_break = strpos($list, mp_store_link(false, true) . '"');
        //if we can't find the page for some reason skip
        if ($temp_break === false) {
            return $list;
        }
        $break = strpos($list, '</a>', $temp_break) + 4;
        $nav = substr($list, 0, $break);
        if (!$this->get_setting('disable_cart')) {
            $nav .= '<ul class="children"><li class="page_item' . (get_query_var('pagename') == 'product_list' ? ' current_page_item' : '') . '"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>';
            $nav .= '<li class="page_item' . (get_query_var('pagename') == 'cart' ? ' current_page_item' : '') . '"><a href="' . mp_cart_link(false, true) . '" title="' . __('Shopping Cart', 'mp') . '">' . __('Shopping Cart', 'mp') . '</a></li>';
            $nav .= '<li class="page_item' . (get_query_var('pagename') == 'orderstatus' ? ' current_page_item' : '') . '"><a href="' . mp_orderstatus_link(false, true) . '" title="' . __('Order Status', 'mp') . '">' . __('Order Status', 'mp') . '</a></li>
</ul>
';
        } else {
            $nav .= '
<ul>
	<li class="page_item' . (get_query_var('pagename') == 'product_list' ? ' current_page_item' : '') . '"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>
</ul>
';
        }
        $nav .= substr($list, $break);
        return $nav;
    }