Plugin Directory

Changeset 3264731


Ignore:
Timestamp:
03/31/2025 09:58:22 PM (12 months ago)
Author:
Elvin.Haci
Message:

1.0.2 stable - small fixes

Location:
cartlink-generator
Files:
13 added
5 edited

Legend:

Unmodified
Added
Removed
  • cartlink-generator/trunk/assets/admin-styles.css

    r3211875 r3264731  
    77.autocomplete-item{padding:5px;cursor:pointer;color:#1176b1;font-weight:bold}
    88#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}
    1015
    1116.wrapautogen{margin:20px}
     
    124129    margin: 20px auto;
    125130    padding: 12px 30px;
    126     background: #007cba;
     131    background: #38b6ff;
    127132    color: #fff;
    128133    font-size: 1.2em;
     
    156161/* Responsive Adjustments */
    157162@media (max-width: 768px) {
    158     #selected-products,#autocomplete-dropdown,#product-search {
     163    #selected-products,#autocomplete-dropdown,#product-search,.autogenresponse {
    159164        width: 90%; max-width: 90% !important;
    160165    }
    161 
    162166    #autocomplete-dropdown, #selected-products {
    163167        max-width: 90%;
  • cartlink-generator/trunk/cartlink-generator.php

    r3211875 r3264731  
    33 * Plugin Name: CartLink Generator for WooCommerce
    44 * 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.1
     5 * Version: 1.0.2
    66 * Author: Guaven Labs
    77 * Text Domain: cartlink-generator
     
    1010 * Requires Plugins: woocommerce
    1111 * WC requires at least: 8.0
    12  * WC tested up to: 9.4
     12 * WC tested up to: 9.8
    1313 */
    1414
     
    1818define( 'GUAVEN_CARTLINK_GENERATOR_PATH', plugin_dir_path( __FILE__ ) );
    1919define( 'GUAVEN_CARTLINK_GENERATOR_URL', plugin_dir_url( __FILE__ ) );
    20 define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0.1.0');
     20define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0.2.0');
    2121
    2222
  • cartlink-generator/trunk/includes/ajax-functions.php

    r3211475 r3264731  
    4848        'products'      => $products,
    4949        'fixed_subtotal' => $fixed_subtotal,
    50         'expiry'        => time() + ( $expire_days * DAY_IN_SECONDS ),
    51     ] );
     50    ] , $expire_days * DAY_IN_SECONDS);
    5251
    5352    // Generate the link
  • cartlink-generator/trunk/includes/hooks.php

    r3211475 r3264731  
    9696    }
    9797}
     98
     99
     100add_filter('woocommerce_update_cart_validation', 'gvnclg_prevent_quantity_change', 10, 4);
     101
     102function 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
     115add_action('woocommerce_cart_loaded_from_session', 'gvnclg_save_initial_cart_quantities');
     116
     117function 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
     129add_action('woocommerce_update_order_review_fragments', 'gvnclg_block_quantity_updates_checkout');
     130
     131function 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
     149add_action('woocommerce_cart_emptied', 'gvnclg_clear_generated_by_cartlink_session');
     150
     151function 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  
    33Tags: woocommerce, cart, quick cart, quick checkout, e-commerce
    44Requires at least: 5.5
    5 Tested up to: 6.7
     5Tested up to: 6.8
    66Requires PHP: 7.0
    77WC requires at least: 8.0
    8 WC tested up to: 9.5
     8WC tested up to: 9.8
    99Requires Plugins: woocommerce
    10 Stable tag: 1.0.1
     10Stable tag: 1.0.2
    1111License: GPLv2 or later
    1212License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6565The plugin automatically deletes expired carts' data created by the plugin itself. This ensures that storage remains efficient and uncluttered.
    6666
     67
     68= Can I forbid customers to update quantities in carts generated by the plugin? =
     69Yes! 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
     74This modifies the redirection logic, allowing you to choose between the cart or checkout page.
     75
    6776== Usage ==
    6877
     
    8897== Changelog ==
    8998
     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
    90104= 1.0.1 =
    91105* UI improvements.
Note: See TracChangeset for help on using the changeset viewer.