From 0b1d7b04b987a85476a4351f142ee0fa686e1fc1 Mon Sep 17 00:00:00 2001 From: Eclipse Srl Date: Fri, 24 Jan 2020 16:03:02 +0100 Subject: [PATCH] added function udesly_quantity_input_cart_item --- README.txt | 5 ++++- includes/misc/woocommerce.php | 34 +++++++++++++++++++++++++++------- udesly-adapter-plugin.php | 4 ++-- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/README.txt b/README.txt index 6cd1c9a..ebfa12f 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Donate link: https://www.udesly.com/ Tags: webflow to wordpress, editor, page builder, layout design, udesly, webflow Requires at least: 5.0 Tested up to: 5.2.3 -Stable tag: 2.0.0.45 +Stable tag: 2.0.0.46 License: GPLv3 or later License URI: https://www.udesly.com/terms-conditions-of-use/#udesly-wordpress-plugin Requires PHP: 5.6.0 @@ -81,6 +81,9 @@ That's all! Absolutely! You can use the Udesly Adapter to create more than one website. == Changelog == += 2.0.0.46 = +* Added function udesly_quantity_input_cart_item + = 2.0.0.45 = * Changed "tap" event to "click" event due to Webflow slider changes diff --git a/includes/misc/woocommerce.php b/includes/misc/woocommerce.php index 745a32d..e215442 100644 --- a/includes/misc/woocommerce.php +++ b/includes/misc/woocommerce.php @@ -369,20 +369,40 @@ function udesly_wc_get_single_product_images() if ($product->get_type() === 'variable') { - - $variations = $product->get_available_variations(); - foreach ($variations as $variation) { - $id = $variation['image_id']; - if (!isset($images[$id])) { - $images[$id] = udesly_wc_get_single_product_image($id); - } + $variations = $product->get_available_variations(); + foreach ($variations as $variation) { + $id = $variation['image_id']; + if (!isset($images[$id])) { + $images[$id] = udesly_wc_get_single_product_image($id); } } + } wp_cache_set("wc_product_images", $images); return $images; } +function udesly_quantity_input_cart_item($_product, $cart_item_key, $cart_item, $classes) { + if ( $_product->is_sold_individually() ) { + $product_quantity = sprintf( '1 ', $cart_item_key ); + } else { + $product_quantity = woocommerce_quantity_input( + array( + 'input_name' => "cart[{$cart_item_key}][qty]", + 'input_value' => $cart_item['quantity'], + 'max_value' => $_product->get_max_purchase_quantity(), + 'min_value' => '0', + 'product_name' => $_product->get_name(), + 'classes' => $classes + ), + $_product, + false + ); + } + + echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok. +} + function udesly_wc_get_single_product_image_lightbox_json($attachment, $product_id) { if (is_numeric($attachment)) { diff --git a/udesly-adapter-plugin.php b/udesly-adapter-plugin.php index 0cdd54b..f2622f2 100644 --- a/udesly-adapter-plugin.php +++ b/udesly-adapter-plugin.php @@ -11,7 +11,7 @@ * Plugin Name: Udesly Adapter * Plugin URI: https://www.udesly.com * Description: This is a support plugin for Udesly (Webflow to WordPress converter) that allows you to enable additional features for your theme. - * Version: 2.0.0.45 + * Version: 2.0.0.46 * Author: Udesly * Author URI: https://www.udesly.com * License: GPL-2.0+ @@ -29,7 +29,7 @@ // Constants defined('UDESLY_ADAPTER_PLUGIN_DIRECTORY_PATH') ?: define('UDESLY_ADAPTER_PLUGIN_DIRECTORY_PATH', plugin_dir_path(__FILE__)); defined('UDESLY_ADAPTER_PLUGIN_DIRECTORY_URL') ?: define('UDESLY_ADAPTER_PLUGIN_DIRECTORY_URL', plugin_dir_url(__FILE__)); -defined('UDESLY_ADAPTER_VERSION') ?: define('UDESLY_ADAPTER_VERSION', "2.0.0.45"); +defined('UDESLY_ADAPTER_VERSION') ?: define('UDESLY_ADAPTER_VERSION', "2.0.0.46"); defined('UDESLY_TEXT_DOMAIN') ?: define('UDESLY_TEXT_DOMAIN', "udesly-adapter-plugin"); defined('UDESLY_ADAPTER_PLUGIN_MISC_PATH') ?: define('UDESLY_ADAPTER_PLUGIN_MISC_PATH', plugin_dir_path(__FILE__) . 'includes/misc/');