Plugin Directory

Changeset 3313992


Ignore:
Timestamp:
06/18/2025 03:26:58 PM (8 months ago)
Author:
makecommerce
Message:

Release 4.0.2

Location:
makecommerce/trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • makecommerce/trunk/README.txt

    r3313304 r3313992  
    44Requires at least: 6.8.1
    55Tested up to: 6.8.1
    6 Stable tag: 4.0.1
     6Stable tag: 4.0.2
    77Requires PHP: 8.1
    88License: GPLv2 or later
     
    6060
    6161== Changelog ==
     62
     63= 4.0.2 2025-06-18 =
     64* Feature - Added support for "Does not fit" parcel machine checkbox
     65* Fix - WooCommerce HPOS compatibility
    6266
    6367= 4.0.1 2025-06-17 =
  • makecommerce/trunk/api/templates/shipping_confirm.php

    r3313138 r3313992  
    7575                        <li class="list-group-item d-flex" style="border: none !important;">
    7676                            <div class="ms-2">
    77                                 <div class="fw-bold"><?php _e('“Does not fit parcel machine” handled more smartly', 'wc_makecommerce_domain'); ?></div>
    78                                 <?php _e('This is now based on package weight and dimensions — no need for manual tagging.', 'wc_makecommerce_domain'); ?>
    79                             </div>
    80                         </li>
    81                         <li class="list-group-item d-flex" style="border: none !important;">
    82                             <div class="ms-2">
    8377                                <div class="fw-bold"><?php _e('Free shipping and coupon logic evolving', 'wc_makecommerce_domain'); ?></div>
    8478                                <?php _e('Settings for free shipping from a certain amount and coupon combinations will return soon in a new, improved interface.', 'wc_makecommerce_domain'); ?>
  • makecommerce/trunk/config.php

    r3313304 r3313992  
    1111 * Start at version 3.0.0 and use SemVer - https://semver.org
    1212 */
    13 define( 'MAKECOMMERCE_VERSION', '4.0.1' );
     13define( 'MAKECOMMERCE_VERSION', '4.0.2' );
    1414define( 'MAKECOMMERCE_PLUGIN_ID', 'makecommerce' );
    1515
     
    2828add_action( 'before_woocommerce_init', function() {
    2929    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     30        $plugin_main_file = plugin_dir_path( __DIR__ ) . 'makecommerce.php';
    3031        // Declare HPOS compatibility - true / false
    31         \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     32        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $plugin_main_file, true );
    3233
    3334        // Declare Blocks compatibility - true / false
    34         \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
     35        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', $plugin_main_file, true );
    3536    }
    3637} );
  • makecommerce/trunk/makecommerce.php

    r3313304 r3313992  
    99 * Plugin URI:            https://makecommerce.net/
    1010 * Description:           Adds MakeCommerce payment gateway and shipping methods to WooCommerce checkout
    11  * Version:               4.0.1
     11 * Version:               4.0.2
    1212 * Author:                Maksekeskus AS
    1313 * Author URI:            https://makecommerce.net/
  • makecommerce/trunk/makecommerce/admin/dashboard.php

    r3313304 r3313992  
    309309            $client = $this->get_client();
    310310            $client->connectShop(
    311                 'userAgent',
    312                 'myIP',
     311                $_SERVER['HTTP_USER_AGENT'] ?? 'unknown',
     312                get_site_url() ?? $_SERVER['REMOTE_ADDR'],
    313313                get_site_url() . '/wp-admin/post.php?post={id}&action=edit'
    314314            );
  • makecommerce/trunk/makecommerce/languages/wc_makecommerce_domain-en.po

    r3313138 r3313992  
    428428msgid "Phone number is required for the chosen shipping method."
    429429msgstr "Phone number is required for the chosen shipping method"
     430
     431#: shipping/product.php:61
     432msgid "Does not fit parcel machine"
     433msgstr "Does not fit parcel machine"
     434
     435#: shipping/product.php:62
     436msgid "When this is checked, parcel machine shipping option is not available for a cart with this product"
     437msgstr "When this is checked, parcel machine shipping option is not available for a cart with this product"
  • makecommerce/trunk/makecommerce/languages/wc_makecommerce_domain-et.po

    r3313138 r3313992  
    430430msgid "Phone number is required for the chosen shipping method."
    431431msgstr "Valitud saatmisviisi jaoks on vaja telefoninumbrit"
     432
     433#: shipping/product.php:61
     434msgid "Does not fit parcel machine"
     435msgstr "Ei sobi pakiautomaati"
     436
     437#: shipping/product.php:62
     438msgid "When this is checked, parcel machine shipping option is not available for a cart with this product"
     439msgstr "Kui see on märgitud, siis ostukorvile selle tootega pakiautomaate tarneviisina ei pakuta"
  • makecommerce/trunk/makecommerce/languages/wc_makecommerce_domain-lt.po

    r3313138 r3313992  
    430430msgid "Phone number is required for the chosen shipping method."
    431431msgstr "Pasirinktam pristatymo būdui reikalingas telefono numeris"
     432
     433#: shipping/product.php:61
     434msgid "Does not fit parcel machine"
     435msgstr "Netelpa į siuntų terminalą"
     436
     437#: shipping/product.php:62
     438msgid "When this is checked, parcel machine shipping option is not available for a cart with this product"
     439msgstr "Kai tai pažymima, užsakymo su šiuo produktu į siuntų terminalus pristatymas negalimas"
  • makecommerce/trunk/makecommerce/languages/wc_makecommerce_domain-lv.po

    r3313138 r3313992  
    431431msgid "Phone number is required for the chosen shipping method."
    432432msgstr "Izvēlētajai piegādes metodei ir nepieciešams tālruņa numurs"
     433
     434#: shipping/product.php:61
     435msgid "Does not fit parcel machine"
     436msgstr "Neder pakomātam"
     437
     438#: shipping/product.php:62
     439msgid "When this is checked, parcel machine shipping option is not available for a cart with this product"
     440msgstr "Kad šis ir atzīmēts, piegādes veids pakomāts nebūs pieejams pirkuma grozam, kas saturēs šo produktu"
  • makecommerce/trunk/makecommerce/languages/wc_makecommerce_domain.pot

    r3313138 r3313992  
    88"Content-Type: text/plain; charset=UTF-8\n"
    99"Content-Transfer-Encoding: 8bit\n"
    10 "POT-Creation-Date: 2025-06-17T07:30:58+00:00\n"
     10"POT-Creation-Date: 2025-06-18T14:15:37+00:00\n"
    1111"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1212"X-Generator: WP-CLI 2.12.0\n"
     
    208208msgstr ""
    209209
    210 #: shipping/blocks/mc-shipping-blocks.php:83
    211 msgid "Phone number is required for the chosen shipping method."
    212 msgstr ""
    213 
    214 #: shipping/blocks/mc-shipping-blocks.php:144
    215 #: shipping/blocks/mc-shipping-blocks.php:162
     210#: shipping/blocks/mc-shipping-blocks.php:110
     211#: shipping/blocks/mc-shipping-blocks.php:128
    216212#: shipping/order.php:83
    217213#: shipping/order.php:150
     
    220216msgstr ""
    221217
    222 #: shipping/blocks/mc-shipping-blocks.php:146
     218#: shipping/blocks/mc-shipping-blocks.php:112
    223219#: shipping/order.php:161
    224220#: shipping/order.php:164
     
    226222msgstr ""
    227223
    228 #: shipping/blocks/mc-shipping-blocks.php:164
     224#: shipping/blocks/mc-shipping-blocks.php:130
    229225#: shipping/order.php:183
    230226#: shipping/order.php:188
     
    244240msgstr ""
    245241
    246 #: shipping/method/method.php:150
     242#: shipping/method/method.php:156
    247243msgid "Unable to retrieve MakeCommerce shipping rates. "
    248244msgstr ""
    249245
    250 #: shipping/method/method.php:167
     246#: shipping/method/method.php:189
    251247msgid "<strong>Parcel machine</strong> is a required field."
    252248msgstr ""
     
    271267msgstr ""
    272268
     269#: shipping/product.php:61
     270msgid "Does not fit parcel machine"
     271msgstr ""
     272
     273#: shipping/product.php:62
     274msgid "When this is checked, parcel machine shipping option is not available for a cart with this product"
     275msgstr ""
     276
    273277#: shipping/shipping.php:516
    274278msgid "Loading pickup points..."
  • makecommerce/trunk/makecommerce/makecommerce.php

    r3313304 r3313992  
    1111 * Start at version 3.0.0 and use SemVer - https://semver.org
    1212 */
    13 define( 'MAKECOMMERCE_VERSION', '4.0.1' );
     13define( 'MAKECOMMERCE_VERSION', '4.0.2' );
    1414define( 'MAKECOMMERCE_PLUGIN_ID', 'makecommerce' );
    1515
  • makecommerce/trunk/makecommerce/payment/gateway/woocommerce/css/makecommerce.css

    r3313304 r3313992  
    1 .makecommerce-payment-methods.payment-method-selected {
     1.makecommerce-payment-methods .payment-method-selected {
    22    border: 2px #32CB64 solid;
    33    box-shadow: none;
    44}
    55
    6 .makecommerce-payment-methods.payment-method-selected > .check {
     6.makecommerce-payment-methods .payment-method-selected > .check {
    77    display: block;
    88    width: 16px;
    99    height: 16px;
    10     background: url(../images/check.svg) no-repeat 0 0;
     10    background: url("https://static.maksekeskus.ee/img/woocommerce/check.svg") no-repeat 0 0;
    1111    position: absolute;
    1212    top: -8px;
     
    1414}
    1515
    16 .payment-method-selected.payment-method.payment-control{
     16.makecommerce-payment-methods .payment-method .payment-control{
    1717    padding: 0px 0px 0px 0px !important;
    1818}
    19 
    2019
    2120/*!* Style the logo image on checkout *!*/
     
    2726    height: 30px !important;
    2827    max-height: 100%;
     28    position: static !important;
    2929}
    30 
    31 
  • makecommerce/trunk/makecommerce/payment/gateway/woocommerce/woocommerce.php

    r3313304 r3313992  
    1313    public $id = MAKECOMMERCE_PLUGIN_ID;
    1414
    15     public $version = '4.0.1';
     15    public $version = '4.0.2';
    1616   
    1717    public $payment_return_url;
  • makecommerce/trunk/makecommerce/shipping/js/pickuppoint.js

    r3313138 r3313992  
    11jQuery(function () {
    2     jQuery(document).on('updated_checkout', function () {
    3         addClassicCheckoutPickupField();
     2    jQuery(document).ready(function() {
     3        initPickupPointInjection();
    44    });
     5    jQuery(document).on('updated_checkout', initPickupPointInjection);
    56});
    67
    7 function addClassicCheckoutPickupField() {
     8
     9
     10function initPickupPointInjection() {
    811    jQuery('.makecommerce-shipping-container').remove();
    912
    10     let method = jQuery('input[name="shipping_method[0]"]:checked').val();
    11     // Fallback if no radio input is checked (only one shipping method with hidden input)
    12     if (!method) {
    13         method = jQuery('input[type="hidden"][name="shipping_method[0]"]').val();
    14     }
     13    let method = jQuery('input[name="shipping_method[0]"]:checked').val()
     14        || jQuery('input[type="hidden"][name="shipping_method[0]"]').val();
    1515
    1616    if (!method?.includes('mc_pickuppoint_')) return;
    1717
    18     let carrier = method.split('_')[2];
    19     let country = jQuery('#mcCustomerCountry').val();
    20     let widthPx = (jQuery('table.shop_table').width() - 40) + 'px';
     18    const carrier = method.split('_')[2];
     19    const country = jQuery('#mcCustomerCountry').val();
     20    const widthPx = (jQuery('table.shop_table').width() - 40) + 'px';
    2121
    22     // Initialize Select2 for loading state
    2322    const $select = insertLoadingSelect(carrier, widthPx);
    2423
    25     // Fetch machine list and populate the same select box
    2624    jQuery.ajax({
    2725        url: '/wp-admin/admin-ajax.php',
     
    4644    select.className = 'pickup-point-select-box';
    4745    select.name = '_mc_machine_id';
    48     let placeholderText = MC_PARCELMACHINE_JS['loadingPlaceholder'] ?? 'Loading pickup points...';
     46    const placeholderText = MC_PARCELMACHINE_JS['loadingPlaceholder'] ?? 'Loading pickup points...';
    4947
    5048    const loadingOption = new Option(placeholderText, '', true, true);
     
    6462    td.colSpan = 2;
    6563    td.appendChild(div);
    66 
    6764    tr.appendChild(td);
    6865
    69     jQuery('.woocommerce-shipping-totals.shipping').after(tr);
     66    const $shippingTotals = jQuery('.woocommerce-shipping-totals.shipping');
     67    if ($shippingTotals.length > 0) {
     68        $shippingTotals.last().after(tr);
     69    }
    7070
    71     const $select = jQuery(select);
    72     $select.select2({
     71    const $selectBox = jQuery(select).prop('disabled', true);
     72    applySelectBox($selectBox, {
    7373        placeholder: placeholderText,
    7474        width: widthPx,
    7575        minimumResultsForSearch: Infinity
    76     }).prop('disabled', true);
     76    });
    7777
    78     return $select;
     78    return $selectBox;
    7979}
    8080
    8181function populatePickupPointSelect($select, machines, widthPx) {
    82     $select.empty(); // Clear loading state
    83 
    84     let placeholderText = MC_PARCELMACHINE_JS['placeholder'] ?? 'Select pickup point';
     82    $select.empty();
     83    $select.prop('disabled', false)
     84    const placeholderText = MC_PARCELMACHINE_JS['placeholder'] ?? 'Select pickup point';
    8585    const placeholder = new Option(placeholderText, '', true, true);
    8686    placeholder.disabled = true;
     
    100100                availability: item.availability
    101101            });
    102 
    103             if (item.selected) {
    104                 $option.prop('selected', true);
    105             }
    106 
     102            if (item.selected) $option.prop('selected', true);
    107103            $optgroup.append($option);
    108104        });
     
    110106    }
    111107
    112     // Re-enable and refresh Select2
    113     $select.prop('disabled', false).select2({
     108    applySelectBox($select, {
    114109        placeholder: placeholderText,
    115110        width: widthPx,
     
    118113        templateResult: customOption
    119114    });
     115}
    120116
    121     focusSelect2Search($select);
     117function applySelectBox($element, options) {
     118    if (typeof $element.selectWoo === 'function') {
     119        $element.selectWoo(options);
     120        focusSelect2Search($element);
     121    } else if (typeof $element.select2 === 'function') {
     122        $element.select2(options);
     123        focusSelect2Search($element);
     124    } else {
     125        console.warn('No Select2 or SelectWoo found');
     126    }
    122127}
    123128
    124129function customOption(option) {
    125130    if (!option.id) return option.text;
    126 
    127131    const el = jQuery(option.element);
    128132    const name = el.data('name') || option.text || '';
     
    130134    const address = el.data('address') || '';
    131135    const zip = el.data('zip') || '';
    132 
    133136    return jQuery(`<span>${name} - ${city}, ${address}, ${zip}</span>`);
    134137}
     
    136139function focusSelect2Search(select) {
    137140    jQuery(select).on('select2:open', function () {
    138         let searchField = jQuery('.select2-container--open').find('input.select2-search__field')[0];
     141        const searchField = jQuery('.select2-container--open').find('input.select2-search__field')[0];
    139142        setTimeout(() => searchField?.focus(), 300);
    140143    });
  • makecommerce/trunk/makecommerce/shipping/method/method.php

    r3313138 r3313992  
    136136
    137137            foreach ($rates as $method => $carriers) {
     138                // If does not fit and is pickuppoint, then do not add shipping rate
     139                if ($method === 'pickuppoint' && !$this->fits_parcel_machine($package)) {
     140                    continue;
     141                }
     142
    138143                foreach ($carriers as $carrier) {
    139144                    $this->add_rate([
    140                         'id' => 'mc_' . $method . '_' . $carrier->carrier,
    141                         'label' => $carrier->title,
    142                         'cost' => $carrier->price / 100,
    143                         'taxes' => '',
    144                         'calc_tax' => 'per_order'
     145                        'id'        => 'mc_' . $method . '_' . $carrier->carrier,
     146                        'label'     => $carrier->title,
     147                        'cost'      => $carrier->price / 100,
     148                        'taxes'     => '',
     149                        'calc_tax'  => 'per_order',
    145150                    ]);
    146151                }
     152
    147153            }
    148154
     
    150156            $this->logger->error(__('Unable to retrieve MakeCommerce shipping rates. ' . json_encode($e->getMessage()), 'wc_makecommerce_domain'), $this->log_context);
    151157        }
     158    }
     159
     160    /**
     161     * Checks if there is a product that doesn't fit in parcelmachine
     162     *
     163     * @since 3.0.0
     164     */
     165    private function fits_parcel_machine( $package ) {
     166
     167        foreach ( $package['contents'] as $line ) {
     168            if ( get_post_meta( $line['product_id'], '_no_parcel_machine', true ) === 'yes' ) {
     169                return false;
     170            }
     171        }
     172
     173        return true;
    152174    }
    153175
  • makecommerce/trunk/makecommerce/shipping/product.php

    r3313138 r3313992  
    1111class Product extends \MakeCommerce\Shipping {
    1212
    13     private $loader;
    14    
    15     /**
    16     * Constructs Label class, defines loader and hooks
    17      *
    18     * @since 3.0.0
    19     */
     13    private $loader;
     14
     15    /**
     16    * Constructs Label class, defines loader and hooks
     17     *
     18    * @since 3.0.0
     19    */
    2020    public function __construct( \MakeCommerce\Loader $loader ) {
     21
    2122        $this->loader = $loader;
    22     }
     23
     24        $this->define_hooks();
     25    }
     26
     27    /**
     28     * Define all wordpress hooks needed for printing stuff and creating labels
     29     *
     30     * @since 3.0.0
     31     */
     32    public function define_hooks() {
     33
     34        $this->loader->add_filter( 'woocommerce_product_options_shipping', $this, 'option_fields' );
     35        $this->loader->add_filter( 'woocommerce_process_product_meta', $this, 'save' );
     36    }
     37
     38    /**
     39     * Save product fields
     40     *
     41     * @since 3.0.0
     42     */
     43    public function save( $post_id ) {
     44        $no_parcel_machine = isset($_POST['_no_parcel_machine']) ? 'yes' : 'no';
     45        update_post_meta($post_id, '_no_parcel_machine', $no_parcel_machine);
     46
     47    }
     48
     49    /**
     50     * Add options to product page
     51     *
     52     * @since 3.0.0
     53     */
     54    public function option_fields( $fields ) {
     55
     56        echo '<div class="options_group">';
     57
     58        woocommerce_wp_checkbox(
     59            array(
     60                'id'            => '_no_parcel_machine',
     61                'label'         => __('Does not fit parcel machine', 'wc_makecommerce_domain'),
     62                'description'   => __('When this is checked, parcel machine shipping option is not available for a cart with this product', 'wc_makecommerce_domain')
     63            )
     64        );
     65
     66        echo '</div>';
     67    }
    2368}
  • makecommerce/trunk/payment/gateway/woocommerce/woocommerce.php

    r3313304 r3313992  
    1212
    1313    public $id = MAKECOMMERCE_PLUGIN_ID;
    14     public $version = '4.0.1';
     14    public $version = '4.0.2';
    1515   
    1616    public $payment_return_url;
Note: See TracChangeset for help on using the changeset viewer.