Plugin Directory

Changeset 3106210


Ignore:
Timestamp:
06/23/2024 01:30:05 PM (21 months ago)
Author:
inspireui
Message:

version 4.14.4

Location:
mstore-api/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • mstore-api/trunk/controllers/flutter-booking.php

    r2926914 r3106210  
    177177    }
    178178
     179    private function findStaffValue($array, $staff_id) {
     180        foreach ( $array as $element ) {
     181            if ($element[$staff_id] != null) {
     182                return $element[$staff_id];
     183            }
     184        }
     185    }
     186
    179187    public function get_staffs($request)
    180188    {
     
    190198        $sql = $wpdb->prepare("SELECT * FROM $table_name WHERE product_id = %s",$product_id);
    191199        $items = $wpdb->get_results($sql);
     200        $qtys = get_post_meta($product_id, '_staff_qtys');
     201        $costs = get_post_meta($product_id, '_staff_base_costs');
    192202        foreach ($items as $item) {
    193203            $user = get_user_by("ID", $item->staff_id);
     204            $quantity = null;
     205            $cost = null;
     206            if (is_array($qtys)) {
     207                $quantity = $this->findStaffValue($qtys, $item->staff_id);
     208            }
     209            if (is_array($costs)) {
     210                $cost = $this->findStaffValue($costs, $item->staff_id);
     211            }
    194212            $results[] = array(
    195213                "id" => $user->ID,
     
    207225                "role" => $user->roles,
    208226                "avatar" => get_avatar_url($user->ID),
     227                "quantity" => $quantity,
     228                "cost" => $cost,
    209229            );
    210230        }
  • mstore-api/trunk/controllers/flutter-user.php

    r3089753 r3106210  
    66{
    77
     8    /**
     9     * Endpoint namespace
     10     *
     11     * @var string
     12     */
     13    protected $namespace = 'api/flutter_user';
     14
    815    public function __construct()
    916    {
    10         $this->namespace = 'api/flutter_user';
    1117    }
    1218
  • mstore-api/trunk/controllers/flutter-woo.php

    r3094904 r3106210  
    663663    }
    664664
     665    private function remove_item_in_cart() {
     666        $items = WC()->cart->get_cart();
     667        foreach ( $items as $item_key => $item ) {
     668            WC()->cart->remove_cart_item($item_key);
     669        }
     670    }
     671
    665672    public function shipping_methods($request)
    666673    {
     
    721728        $shipping_methods = WC()->shipping->calculate_shipping(WC()->cart->get_shipping_packages());
    722729        $required_shipping = WC()->cart->needs_shipping() && WC()->cart->show_shipping();
     730        $this->remove_item_in_cart();
    723731
    724732        if(count( $shipping_methods) == 0){
     
    790798        }
    791799        $payment_methods = WC()->payment_gateways->get_available_payment_gateways();
     800        $this->remove_item_in_cart();
    792801        $results = [];
    793802        foreach ($payment_methods as $key => $value) {
  • mstore-api/trunk/controllers/helpers/product-management.php

    r3094904 r3106210  
    1212    protected function get_product_item($id)
    1313    {
    14         if (!wc_get_product($id)) {
     14        $result = wc_get_product($id);
     15        if (!$result) {
    1516            return $this->sendError(
    1617                "invalid_product",
     
    1920            );
    2021        }
    21         return wc_get_product($id);
     22        return $result;
    2223    }
    2324
     
    227228        if ($user_id) {
    228229            $user = get_userdata($user_id);
    229             $is_admin = $user != false ? in_array('administrator', (array)$user->roles) : false;
     230            $is_admin = $user != false ? (in_array('administrator', (array)$user->roles) || in_array('shop_manager', (array)$user->roles)) : false;
    230231            $vendor_id = absint($user_id);
    231232        }
  • mstore-api/trunk/functions/index.php

    r3098380 r3106210  
    390390}
    391391
     392function addYITHBadgeToMetaResponse($response, $product){
     393    if (function_exists( 'yith_wcbm_get_product_badges' )) {
     394       // Add badge to product.
     395        $badges_to_show = yith_wcbm_get_product_badges( $product );
     396        $badges_to_show = apply_filters( 'yith_wcbm_badges_to_show_on_product', $badges_to_show, $product );
     397
     398        $badges = array();
     399
     400        foreach ( $badges_to_show as $badge_id ) {
     401            $badge_id = yith_wcbm_wpml_translate_badge_id( $badge_id );
     402            $badge    = yith_wcbm_get_badge_object( $badge_id );
     403
     404            if ( $badge && $badge->is_enabled() ) {
     405                $data = $badge->get_data();
     406                // If badge is image, get image url.
     407                if ( $badge->get_type() === 'image' ) {
     408                    $image_url = $badge->get_image_url();
     409                    if (strpos($image_url, 'http') == false) {
     410                        $is_https = strpos(home_url(), 'https') == true ;
     411                        $image_url = ($is_https ? 'https:' : 'http:').$image_url;
     412                     }
     413                    $data['image_url'] = $image_url;
     414                }
     415                $badges[] = $data;
     416            }
     417        }
     418
     419        $meta_data = $response->data['meta_data'];
     420        $meta_data[] = array(
     421                'id'    => '_yith_wcbm_badges',
     422                'key'   => '_yith_wcbm_badges',
     423                'value' => $badges,
     424        );
     425
     426        $response->data['meta_data'] = $meta_data;
     427
     428        return $response;
     429    }
     430}
     431
    392432function customProductResponse($response, $object, $request)
    393433{
     
    535575        if ($terms != false && count($terms) > 0 && $terms[0]->name == 'appointment') {
    536576            $response->data['type'] = 'appointment';
     577            $response->data['appointment_duration'] = $product->get_duration();
     578            $response->data['appointment_duration_unit'] = $product->get_duration_unit();
    537579        }
    538580    }
     
    555597    /* YITH WooCommerce Barcodes and QR Codes Premium */
    556598    $response = addQRCodeUrlToMetaResponse($response);
     599
     600    /* YITH WooCommerce Badge Management Premium */
     601    $response = addYITHBadgeToMetaResponse($response, $product);
    557602
    558603    $blackListKeys = ['yoast_head','yoast_head_json','_links'];
  • mstore-api/trunk/mstore-api.php

    r3098380 r3106210  
    44 * Plugin URI: https://github.com/inspireui/mstore-api
    55 * Description: The MStore API Plugin which is used for the FluxBuilder and FluxStore Mobile App
    6  * Version: 4.14.4
     6 * Version: 4.14.5
    77 * Author: FluxBuilder
    88 * Author URI: https://fluxbuilder.com
     
    5656class MstoreCheckOut
    5757{
    58     public $version = '4.14.4';
     58    public $version = '4.14.5';
    5959
    6060    public function __construct()
  • mstore-api/trunk/readme.txt

    r3098380 r3106210  
    44Requires at least: 4.4
    55Tested up to:      6.5.3
    6 Stable tag:        4.14.4
     6Stable tag:        4.14.5
    77License:           GPL-2.0
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 4.14.5 =
     52  * Support YITH WooCommerce Badge Management Premium plugin
     53
    5154= 4.14.4 =
    5255  * Push notification to admin when has new order
Note: See TracChangeset for help on using the changeset viewer.