Plugin Directory

Changeset 2309299


Ignore:
Timestamp:
05/21/2020 07:57:04 AM (6 years ago)
Author:
rnlab
Message:

update: cart

Location:
mobile-builder/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mobile-builder/trunk/api/class-mobile-builder-cart.php

    r2307562 r2309299  
    199199            $image = wp_get_attachment_image_src( get_post_thumbnail_id( $_product->get_id() ), 'single-post-thumbnail' );
    200200            if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 ) {
     201
     202                if ( WC()->cart->display_prices_including_tax() ) {
     203                    $product_price = wc_get_price_including_tax( $_product );
     204                } else {
     205                    $product_price = wc_get_price_excluding_tax( $_product );
     206                }
     207
    201208                $items[ $cart_item_key ]['thumbnail']            = $_product->get_image();
    202209                $items[ $cart_item_key ]['thumb']                = $image[0];
    203210                $items[ $cart_item_key ]['is_sold_individually'] = $_product->is_sold_individually();
    204211                $items[ $cart_item_key ]['name']                 = $_product->get_name();
    205                 $items[ $cart_item_key ]['price']                = WC()->cart->get_product_price( $_product );
     212                $items[ $cart_item_key ]['price']                = $product_price;
     213                $items[ $cart_item_key ]['price_html']           = WC()->cart->get_product_price( $_product );
    206214                $items[ $cart_item_key ]['vendor_id']            = $vendor_id;
    207215                $items[ $cart_item_key ]['store']                = $vendor_id ? $store_user = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ) : null;
     
    211219
    212220        return array(
    213             'items'  => $items,
    214             'totals' => WC()->cart->get_totals(),
     221            'items'   => $items,
     222            'totals'  => WC()->cart->get_totals(),
     223            'coupons' => WC()->cart->get_applied_coupons(),
    215224        );
    216225    }
     
    395404        wp_send_json(
    396405            array(
    397                 'result'    => empty( $messages ) ? 'success' : 'failure',
    398                 'messages'  => $messages,
    399                 'reload'    => $reload_checkout,
    400                 'nonce'     => wp_create_nonce( 'woocommerce-process_checkout' ),
    401                 'fragments' => apply_filters(
    402                     'woocommerce_update_order_review_fragments',
    403                     array(
    404                         '.woocommerce-checkout-review-order-table' => $woocommerce_order_review,
    405                         '.woocommerce-checkout-payment'            => $woocommerce_checkout_payment,
    406                     )
    407                 ),
     406                'result'   => empty( $messages ) ? 'success' : 'failure',
     407                'messages' => $messages,
     408                'reload'   => $reload_checkout,
     409                'nonce'    => wp_create_nonce( 'woocommerce-process_checkout' ),
     410                'totals'   => WC()->cart->get_totals(),
    408411            )
    409412        );
    410413    }
    411414
     415    /**
     416     *
     417     * Checkout progress
     418     *
     419     * @throws Exception
     420     */
    412421    public function mobile_builder_checkout() {
    413 
    414422        wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true );
     423        wc_maybe_define_constant( 'DOING_AJAX', true );
    415424        WC()->checkout()->process_checkout();
    416425        wp_die( 0 );
     
    423432     */
    424433    public function shipping_methods() {
    425 
    426 //      global $woocommerce;
    427 
    428 //      WC()->customer->set_props(
    429 //          array(
    430 //              'shipping_country'   => 'VE',
    431 //              'shipping_state'     => $request->get_param( 'state') ) ? wc_clean( wp_unslash( $request->get_param( 'state') ) ) : null,
    432 //              'shipping_postcode'  => $request->get_param( 'postcode') ) ? wc_clean( wp_unslash( $request->get_param( 'postcode') ) ) : null,
    433 //              'shipping_city'      => $request->get_param( 'city') ) ? wc_clean( wp_unslash( $request->get_param( 'city') ) ) : null,
    434 //              'shipping_address_1' => $request->get_param( 'address') ) ? wc_clean( wp_unslash( $request->get_param( 'address') ) ) : null,
    435 //              'shipping_address_2' => $request->get_param( 'address_2') ) ? wc_clean( wp_unslash( $request->get_param( 'address_2') ) ) : null,
    436 //          )
    437 //      );
    438 
    439 //      $data = 'billing_first_name=&billing_last_name=&billing_company=&billing_country=VE&billing_address_1=&billing_address_2=&billing_city=&billing_state=&billing_postcode=&billing_phone=&billing_email=admin%40gmail.com&shipping_first_name=&shipping_last_name=&shipping_company=&shipping_country=VN&shipping_address_1=&shipping_address_2=&shipping_postcode=&shipping_city=&shipping_state=&order_comments=&shipping_method%5B15%5D=free_shipping%3A3&shipping_method%5B18%5D=free_shipping%3A3&payment_method=bacs&woocommerce-process-checkout-nonce=a1194af571&_wp_http_referer=%2Fwpdev%2F%3Fwc-ajax%3Dupdate_order_review';
    440 //
    441 //
    442 //      do_action( 'woocommerce_checkout_update_order_review', isset( $data ) ? wp_unslash( $data ) : '' );
    443 
    444 //      WC()->customer->save();
    445434
    446435        // Calculate shipping before totals. This will ensure any shipping methods that affect things like taxes are chosen prior to final totals being calculated. Ref: #22708.
     
    463452                $product_names = apply_filters( 'woocommerce_shipping_package_details_array', $product_names, $package );
    464453            }
    465 
    466 //          print_r($package['rates']['flat_rate:2']->get_label()); die;
    467 
    468 //          $rate = $package['rates'][  ];
    469 
    470 //          echo $rate->get_label();
    471454
    472455            $available_methods = array();
  • mobile-builder/trunk/includes/class-mobile-builder.php

    r2307562 r2309299  
    208208        // Cart
    209209        $plugin_cart = new Mobile_Builder_Cart( $this->get_plugin_name(), $this->get_version() );
     210        $this->loader->add_action( 'rest_api_init', $plugin_cart, 'add_api_routes', 10 );
    210211        $this->loader->add_action( 'wp_loaded', $plugin_cart, 'mobile_builder_pre_car_rest_api', 5 );
    211         $this->loader->add_action( 'rest_api_init', $plugin_cart, 'add_api_routes', 10 );
    212212//      $this->loader->add_filter( 'woocommerce_is_rest_api_request', $plugin_cart, 'simulate_as_not_rest', 10 );
    213213        $this->loader->add_filter( 'woocommerce_persistent_cart_enabled', $plugin_cart, 'mobile_builder_woocommerce_persistent_cart_enabled' );
Note: See TracChangeset for help on using the changeset viewer.