Changeset 3264731
- Timestamp:
- 03/31/2025 09:58:22 PM (12 months ago)
- Location:
- cartlink-generator
- Files:
-
- 13 added
- 5 edited
-
tags/1.0.2 (added)
-
tags/1.0.2/assets (added)
-
tags/1.0.2/assets/admin-scripts.js (added)
-
tags/1.0.2/assets/admin-styles.css (added)
-
tags/1.0.2/cartlink-generator.php (added)
-
tags/1.0.2/includes (added)
-
tags/1.0.2/includes/admin-page.php (added)
-
tags/1.0.2/includes/ajax-functions.php (added)
-
tags/1.0.2/includes/hooks.php (added)
-
tags/1.0.2/includes/utilities.php (added)
-
tags/1.0.2/readme.txt (added)
-
tags/1.0.2/templates (added)
-
tags/1.0.2/templates/admin-page.php (added)
-
trunk/assets/admin-styles.css (modified) (3 diffs)
-
trunk/cartlink-generator.php (modified) (3 diffs)
-
trunk/includes/ajax-functions.php (modified) (1 diff)
-
trunk/includes/hooks.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cartlink-generator/trunk/assets/admin-styles.css
r3211875 r3264731 7 7 .autocomplete-item{padding:5px;cursor:pointer;color:#1176b1;font-weight:bold} 8 8 #product-search{width:100%} 9 .autogenresponse{margin-top:30px;margin-left:10px;margin-right:10px} 9 .autogenresponse{ 10 margin-top: 40px; 11 width: calc(60% - 40px); 12 margin-left: auto; 13 margin-right: auto; 14 } 10 15 11 16 .wrapautogen{margin:20px} … … 124 129 margin: 20px auto; 125 130 padding: 12px 30px; 126 background: # 007cba;131 background: #38b6ff; 127 132 color: #fff; 128 133 font-size: 1.2em; … … 156 161 /* Responsive Adjustments */ 157 162 @media (max-width: 768px) { 158 #selected-products,#autocomplete-dropdown,#product-search {163 #selected-products,#autocomplete-dropdown,#product-search,.autogenresponse { 159 164 width: 90%; max-width: 90% !important; 160 165 } 161 162 166 #autocomplete-dropdown, #selected-products { 163 167 max-width: 90%; -
cartlink-generator/trunk/cartlink-generator.php
r3211875 r3264731 3 3 * Plugin Name: CartLink Generator for WooCommerce 4 4 * Description: Create dynamic cart links with pre-filled products, quantities, and custom prices, perfect for businesses interacting via chat to reduce purchase steps and drive faster conversions. 5 * Version: 1.0. 15 * Version: 1.0.2 6 6 * Author: Guaven Labs 7 7 * Text Domain: cartlink-generator … … 10 10 * Requires Plugins: woocommerce 11 11 * WC requires at least: 8.0 12 * WC tested up to: 9. 412 * WC tested up to: 9.8 13 13 */ 14 14 … … 18 18 define( 'GUAVEN_CARTLINK_GENERATOR_PATH', plugin_dir_path( __FILE__ ) ); 19 19 define( 'GUAVEN_CARTLINK_GENERATOR_URL', plugin_dir_url( __FILE__ ) ); 20 define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0. 1.0');20 define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0.2.0'); 21 21 22 22 -
cartlink-generator/trunk/includes/ajax-functions.php
r3211475 r3264731 48 48 'products' => $products, 49 49 'fixed_subtotal' => $fixed_subtotal, 50 'expiry' => time() + ( $expire_days * DAY_IN_SECONDS ), 51 ] ); 50 ] , $expire_days * DAY_IN_SECONDS); 52 51 53 52 // Generate the link -
cartlink-generator/trunk/includes/hooks.php
r3211475 r3264731 96 96 } 97 97 } 98 99 100 add_filter('woocommerce_update_cart_validation', 'gvnclg_prevent_quantity_change', 10, 4); 101 102 function gvnclg_prevent_quantity_change($passed, $cart_item_key, $values, $quantity) { 103 // Check if the cart was generated by CartLink Generator 104 if (defined('CARTGENERATOR_FORBID_QUANTITY_UPDATE') and WC()->session->get('generated_by_cartlink')) { 105 // Display error message and prevent update 106 wc_add_notice(__('You can\'t modify this cart.', 'cartlink-generator'), 'error'); 107 return false; // Prevent the update 108 } 109 return $passed; // Allow the update 110 } 111 112 113 114 115 add_action('woocommerce_cart_loaded_from_session', 'gvnclg_save_initial_cart_quantities'); 116 117 function gvnclg_save_initial_cart_quantities() { 118 if (WC()->session->get('generated_by_cartlink')) { 119 $initial_quantities = []; 120 121 foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { 122 $initial_quantities[$cart_item_key] = $cart_item['quantity']; 123 } 124 125 WC()->session->set('cartlink_initial_quantities', $initial_quantities); 126 } 127 } 128 129 add_action('woocommerce_update_order_review_fragments', 'gvnclg_block_quantity_updates_checkout'); 130 131 function gvnclg_block_quantity_updates_checkout($fragments) { 132 if (WC()->session->get('generated_by_cartlink')) { 133 $initial_quantities = WC()->session->get('cartlink_initial_quantities') ?: []; 134 135 foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { 136 if (isset($initial_quantities[$cart_item_key]) && $cart_item['quantity'] != $initial_quantities[$cart_item_key]) { 137 // Reset the quantity to the original value 138 WC()->cart->set_quantity($cart_item_key, $initial_quantities[$cart_item_key], true); 139 // Add an error notice 140 wc_add_notice(__('You can\'t modify this cart.', 'cartlink-generator'), 'error'); 141 } 142 } 143 } 144 145 return $fragments; 146 } 147 148 149 add_action('woocommerce_cart_emptied', 'gvnclg_clear_generated_by_cartlink_session'); 150 151 function gvnclg_clear_generated_by_cartlink_session() { 152 // Check if the session data exists 153 if (WC()->session->get('generated_by_cartlink')) { 154 // Clear the 'generated_by_cartlink' session data 155 WC()->session->__unset('generated_by_cartlink'); 156 } 157 } -
cartlink-generator/trunk/readme.txt
r3214792 r3264731 3 3 Tags: woocommerce, cart, quick cart, quick checkout, e-commerce 4 4 Requires at least: 5.5 5 Tested up to: 6. 75 Tested up to: 6.8 6 6 Requires PHP: 7.0 7 7 WC requires at least: 8.0 8 WC tested up to: 9. 58 WC tested up to: 9.8 9 9 Requires Plugins: woocommerce 10 Stable tag: 1.0. 110 Stable tag: 1.0.2 11 11 License: GPLv2 or later 12 12 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 65 65 The plugin automatically deletes expired carts' data created by the plugin itself. This ensures that storage remains efficient and uncluttered. 66 66 67 68 = Can I forbid customers to update quantities in carts generated by the plugin? = 69 Yes! To set this limit just add this code to your theme's `functions.php` file: 70 71 define( 'CARTGENERATOR_FORBID_QUANTITY_UPDATE', true ); 72 73 74 This modifies the redirection logic, allowing you to choose between the cart or checkout page. 75 67 76 == Usage == 68 77 … … 88 97 == Changelog == 89 98 99 = 1.0.2 = 100 * "Expire-dates are always 1 hour" bug fix 101 * Added new feature - Prevent product quantity update for generated carts. 102 * Delete the trace of cart generator when cart gets emptied. 103 90 104 = 1.0.1 = 91 105 * UI improvements.
Note: See TracChangeset
for help on using the changeset viewer.