Plugin Directory

Changeset 2703352


Ignore:
Timestamp:
04/01/2022 01:39:16 PM (4 years ago)
Author:
nappssolutions
Message:

tagging version 1.0.4

Location:
napps
Files:
54 added
5 edited

Legend:

Unmodified
Added
Removed
  • napps/trunk/includes/class-core.php

    r2678957 r2703352  
    2424
    2525        }
    26        
     26
    2727        /**
    2828         * From a order query param, auth current user and redirect to the payment page if allowed
     
    3333         */
    3434        public function get_woocommerce_checkout( WP_REST_Request $request ) {
     35
     36            // Get order id
    3537            $orderID = $request->get_param("order");
     38
     39            // Get current auth user
    3640            $customer = get_current_user_id();
    3741           
     42            // Check if user is not loggedIn
    3843            if($orderID == null || !$customer) {
    3944                wp_redirect(home_url('/napps/order/failed'));
     
    4247           
    4348            $order = wc_get_order($orderID);
     49
     50            // If order is not from auth user
    4451            if(!$order || $customer != $order->get_customer_id()) {
    4552                wp_redirect(home_url('/napps/order/failed'));
     
    4754            }
    4855
    49             if($order && ( $order->has_status( 'pending' ) || $order->has_status( 'unpaid' ) )) {
     56
     57            // Auth current customer based on his jwt token
     58            wp_clear_auth_cookie();
     59            wp_set_current_user( $customer );
     60            wp_set_auth_cookie($customer, true, is_ssl());
     61
     62            // If we failed to set cookie for napps_mobile ignore
     63            // Some wordpress sites were reporting that COOKIEPATH was not correctly set
     64            try {
     65                setcookie('napps_mobile', 'true', strtotime('+1 day'), COOKIEPATH, COOKIE_DOMAIN, true, true);
     66            } catch(Exception $e) {}
     67
     68            if( $order->has_status( 'pending' ) || $order->has_status( 'unpaid' ) ) {
    5069
    5170                try {
     
    6079                    );
    6180
    62                     // Auth current customer based on his jwt token
    63                     wp_clear_auth_cookie();
    64                     wp_set_current_user( $customer );
    65                     wp_set_auth_cookie($customer, true, is_ssl());
    66 
    6781                    // Redirect to payment page
    6882                    wp_redirect($pay_now_url);
     
    7488               
    7589            } else {
    76                 wp_redirect(home_url('/napps/order/failed'));
     90                wp_redirect($order->get_view_order_url());
    7791                exit;
    7892            }
  • napps/trunk/includes/class-smartbanner.php

    r2678957 r2703352  
    4848            $this->options = get_option('nappsSmartAppBanner');
    4949
    50             if(function_exists('is_checkout')) {
    51                 $isPaymentPage = is_checkout();
    52             } else {
    53                 $isPaymentPage = false;
    54             }
    55 
    56             if(!$isPaymentPage) {
     50            $showSmartbanner = true;
     51
     52            if (isset($_COOKIE['napps_mobile']) && $_COOKIE['napps_mobile'] == 'true') {
     53                $showSmartbanner = false;
     54            }
     55
     56            if($showSmartbanner) {
    5757               
    5858                //Hooks
  • napps/trunk/includes/class-woocommerce.php

    r2672465 r2703352  
    1010use WC_Shipping_Zones;
    1111use WC_Webhook;
    12 
     12use WC_Order;
    1313
    1414if (!class_exists('NappsWooCommerce')) {
     
    3939            add_filter( 'woocommerce_webhook_topic_hooks', array($this, 'add_new_topic_hooks') );
    4040
     41            add_action( 'woocommerce_rest_insert_shop_order_object', array( $this, 'on_rest_new_order' ), 10, 2);
     42
    4143            if(is_admin())
    4244            {
     
    5456                add_action( 'woocommerce_init', array( $this, 'woocommerce_init' ), 10, 0 );
    5557                add_action( 'woocommerce_admin_order_data_after_order_details', array( $this, 'woocommerce_is_napps_admin_order_fields'), 10, 1 );
     58               
    5659            }
    5760
     
    6164        }
    6265
    63         function woocommerce_is_napps_admin_order_fields($order) {
     66        /*
     67        *   Integration with third party plugins
     68        *   Some plugins only take in account orders created using website checkout
     69        *   Trigger this event for orders created from the rest api
     70        */
     71        public function on_rest_new_order($order, $request) {
     72           
     73            if( $order instanceof WC_Order ){
     74                $order_id = $order->get_id();
     75            }else{
     76                $order_id = $order->ID;
     77            }
     78           
     79            do_action('woocommerce_checkout_order_processed', $order_id, $request, $order);
     80        }
     81
     82        public function woocommerce_is_napps_admin_order_fields($order) {
    6483            ?>
    6584           
  • napps/trunk/napps.php

    r2678957 r2703352  
    33 * Plugin Name: NAPPS
    44 * Description: Plugin to complement the napps E-commerce solution. More on https://napps.pt
    5  * Version:     1.0.3
     5 * Version:     1.0.4
    66 * Author:      NAPPS
    77 * Author URI:  https://napps.pt
     
    3636define( 'NAPPS_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
    3737define( 'NAPPS_PLUGIN_FILE',  __FILE__ );
    38 define( 'NAPPS_VERSION', '1.0.3' );
     38define( 'NAPPS_VERSION', '1.0.4' );
    3939define( 'NAPPS_REST_PREFIX', 'napps/v1' );
    4040
  • napps/trunk/readme.txt

    r2678957 r2703352  
    55Requires at least: 4.7
    66Tested up to: 5.8
    7 Stable tag: 1.0.3
     7Stable tag: 1.0.4
    88Requires PHP: 5.6
    99License: GPLv2
     
    7777== Changelog ==
    7878
     79= 1.0.4 =
     80
     81* New - Order detail redirect page
     82
    7983= 1.0.3 =
    8084
Note: See TracChangeset for help on using the changeset viewer.