Support » Plugin: Woocommerce Custom Fields For Variation » For Everyone Who Has A Broken Plugin

  • There doesn’t seem to be any support coming for this and for those that had issues with this plugin here is what I have done.

    For me, not only upgrading from 1.1.4 to 1.1.5 broke things, but also running 1.1.4 before the updrade, I lost the ability to add and view (even though existing ones were working) custom options to variations.

    So firstly, this is how I fixed the broken upgrade.

    Remove the plugin don’t worry if you custom options set, they will stop working, but will return when you re-install.

    Download version 1.1.4 from here

    https://downloads.wordpress.org/plugin/woo-custom-fields-for-variation.1.1.4.zip

    and install it either manually or upload using add new plugin and activate it.

    Then download version 1.1.5 from here

    https://downloads.wordpress.org/plugin/woo-custom-fields-for-variation.1.1.5.zip

    Open it and you will notice there are just 3 upgrade files, this is why it breaks. Manually copy these 3 files to overwrite then ones in the plugin folder via ftp (or however you manually upload files).

    This fixes and upgrades to 1.1.5

    If like me, the options are not available in the variations.

    Simply go to the “Phoenix/Variations Options” in the dashboard menu un-tick “Enable Custom Options” click Save and then re-tick “Enable Custom Options” and Save.

    This fixed it for me!

Viewing 4 replies - 1 through 4 (of 4 total)
  • I may need to try this. Are there any similar plugin options that can provide a text field based on the selected variable? I fear one day my site will be totally broken and would like to find a better supported plugin. It’s a shame because this has everything I need. Not to mention all the work required after switching plugins.

    • This reply was modified 9 months, 1 week ago by forwerd.
    Thread Starter craigrogersuk

    (@craigrogersuk)

    Actually, since I fixed it yesterday I upgraded WP to 5.6 and the field stopped showing….

    So I’ve now deleted this plug in and I’m using Product Addons For Woocommerce

    It handles text fields much better, works and is confirmed compatible with WP5.6

    https://en-gb.wordpress.org/plugins/woo-custom-product-addons/

    To make this plugin work again with WP 5.6, you must update options.js with this code:

    jQuery(document).ready(function ($) {
        $(this).on('change', '.custom_field, .custom_textarea, input.qty', function () {
            $(this).trigger('show_options_final_total');
        });
    
            $(this).trigger('show_options_final_total');
    
        jQuery(document).on('found_variation', 'form.cart', function (event, variation) {
            var $variation_form = $(this);
    
            var $totals = $variation_form.find('#product-options-var-total');
    
            if ($(variation.price_html).find('.amount:last').size()) {
                product_price = $(variation.price_html).find('.amount:last').text();
                product_price = product_price.replace(woocommerce_custom_var_options_params.thousand_separator, '');
                product_price = product_price.replace(woocommerce_custom_var_options_params.decimal_separator, '.');
                product_price = product_price.replace(/[^0-9\.]/g, '');
                product_price = parseFloat(product_price);
    
                $totals.data('product-price', product_price);
            }
    
            $variation_form.trigger('show_options_final_total');
        });
    
        $(this).on('show_options_final_total', function () {
    
            var option_total = 0;
    
            var product_price = $(this).find('#product-options-var-total').data('product-price');
    
            if (typeof product_price == 'undefined') {
                var product_price = $('#product-options-var-total').attr('product-price');
            }
    
            product_price = parseFloat(product_price);
    
            var product_total_price = 0;
    
            var final_total = 0;
    
            $('.custom-variation').each(function () {
    
                var option_price = 0;
    
                option_price = $(this).attr('data-price');
                var value_entered = $(this).val();
    
                if (value_entered != '' || option_price == 0) {
                    option_total = parseFloat(option_total) + parseFloat(option_price);
                }
    
            });
    
            var qty = $('.qty').val();
    
            if (option_total > 0 && qty > 0) {
    
                option_total = option_total * qty;
    
                option_total = option_total.toFixed(2);
    
                option_total = parseFloat(option_total);
    
                //console.log( product_price );
    
                if (product_price) {
    
                    product_total_price = product_price * qty;
    
                    product_total_price = product_total_price.toFixed(2);
    
                    product_total_price = parseFloat(product_total_price);
    
                }
    
                final_total = option_total + product_total_price;
    
                final_total = final_total.toFixed(2);
    
                html = '';
    
                if (woocommerce_custom_var_options_params.show_op == 1) {
                    html = html + '<dl class="product-options-price"><dt> ' + woocommerce_custom_var_options_params.op_show + ' </dt><dd><strong><span class="amount">' + woocommerce_custom_var_options_params.currency_symbol + option_total + '</span></strong></dd>';
                }
    
                if (final_total) {
    
                    if (woocommerce_custom_var_options_params.show_ft == 1) {
                        html = html + '<dt>' + woocommerce_custom_var_options_params.ft_show + '</dt><dd><strong><span class="amount">' + woocommerce_custom_var_options_params.currency_symbol + final_total + '</span></strong></dd>';
                    }
    
                }
    
                html = html + '</dl>';
    
                $('#product-options-var-total').html(html);
    
            } else {
    
                $('#product-options-var-total').html('');
            }
    
        });
    
        $(this).find('.variations select').change();
    
    	var variation_id = '';
    	jQuery(document).on('found_variation', 'form.cart', function (event, variation) {
    		main_col();
    	});
    	jQuery('.variations select').on('ready change', function () {
    		jQuery(document).on('found_variation', 'form.cart', function (event, variation) {
    			main_col();
    		});
    		jQuery("body").on('click', '.reset_variations', function () {
    			main_col();
    		});
    	});
    
        function main_col() {
    
            $('#product-options-var-total').html('');
            variation_id = jQuery(".variation_id").val();
    
            // alert(variation_id);
    
            if (variation_id !== '' && variation_id !== undefined && variation_id !== 0) {
                jQuery('.phoen_minss').each(function () {
                    jQuery(this).find('input').val('');
                    jQuery(this).find('textarea').val('');
    
                    if (jQuery(this).hasClass('phoenwwe_' + variation_id)) {
                        jQuery(this).css('display', 'block');
                    } else {
                        jQuery(this).css('display', 'none');
                    }
                });
            } else {
                jQuery('.phoen_minss').each(function () {
                    jQuery(this).find('input').val('');
                    jQuery(this).find('textarea').val('');
    
                    jQuery(this).css('display', 'none');
    
                });
            }
        }
    
    });
    kineticartist

    (@kineticartist)

    I did the combination of @craigrogersuk steps then replaced the /wp-content/plugins/woo-custom-fields-for-variation/assets/js/options.js with @ideatic’s code above and is now working on WordPress 5.7.2 for a variation and shows either the text box or text area quite nicely I might add.

    Thank you both for the fix

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.