Post by MorrisJohnson » Sun Feb 18, 2018 2:09 am

This vqmod should help with getting OpenStock 2 to work with Journal theme. Hope it helps.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
    <id>OpenStock 2 Journal Theme</id>
    <version>1.0</version>
    <vqmver>2.x</vqmver>
    <author>xxx</author>
    <file name="catalog/view/theme/*/template/product/product.tpl">
        <operation>
            <search position="replace"><![CDATA[<li class="p-stock"><?php echo $text_stock; ?> <span class="journal-stock <?php echo isset($stock_status) ? $stock_status : ''; ?>"><?php echo $stock; ?></span></li>]]></search>
            <add><![CDATA[<?php if ($has_option == 0) { ?><li class="p-stock"><?php echo $text_stock; ?> <span class="journal-stock <?php echo isset($stock_status) ? $stock_status : ''; ?>"><?php echo $stock; ?></span></li><?php } ?>]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[<li class="p-model"><?php echo $text_model; ?> <span class="p-model" itemprop="model"><?php echo $model; ?></span></li>]]></search>
            <add><![CDATA[<li class="p-model os-model"><?php echo $text_model; ?> <span class="p-model" itemprop="model"><?php echo $model; ?></span></li>]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[<select name="option[<?php echo $option['product_option_id']; ?>]" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control">]]></search>
            <add><![CDATA[<select name="option[<?php echo $option['product_option_id']; ?>]" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control option-choice">]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[<input type="radio" name="option]]></search>
            <add><![CDATA[<input class="option-choice" type="radio" name="option]]></add>
        </operation>
        <operation>
            <search position="before" offset="1"><![CDATA[<?php if ($recurrings) { ?>]]></search>
            <add><![CDATA[<input type="hidden" name="option_numbers" value="<?php echo $i; ?>" id="option-numbers" />]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[<div class="form-group cart <?php echo isset($labels) && is_array($labels) && isset($labels['outofstock']) ? 'outofstock' : ''; ?>">]]></search>
            <add><![CDATA[<div id="product-cart">]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[<?php if ($minimum > 1) { ?>]]></search>
            <add><![CDATA[</div>]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[foreach ($options as $option) { ?>]]></search>
            <add><![CDATA[$i = 0; foreach ($options as $option) { ?>]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[<?php if ($option['type'] == 'radio') { ?>]]></search>
            <add><![CDATA[<?php if ($option['type'] == 'radio') { $i++;?>]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[<?php if ($option['type'] == 'select') {]]></search>
            <add><![CDATA[<?php if ($option['type'] == 'select') { $i++;]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[<?php if ($option_value['price']) { ?>]]></search>
            <add><![CDATA[<?php if ($option_value['price'] && $has_option != 1) { ?>]]></add>
        </operation>
<!--         <operation>
            <search position="replace"><![CDATA[<li><a class="thumbnail"]]></search>
            <add><![CDATA[<li class="os-image-main"><a class="thumbnail"]]></add>
        </operation> -->
        <operation>
            <search position="before"><![CDATA[<?php echo $footer; ?>]]></search>
            <add><![CDATA[
<?php if ($has_option == 1) { ?>
    <script type="text/javascript"><!--
    var original_thumb = '<?php echo str_replace("'", "\'", $thumb); ?>';
    var original_pop = '<?php echo str_replace("'", "\'", $popup); ?>';
    var openstock_dependant_options = '<?php echo $openstock_dependant_options; ?>';

    optionChoice();

    $('.option-choice').change(function() {
        optionChoice(this);
    });

    function optionChoice(that) {
        if (typeof that === 'undefined') { that = ''; }

        $('.os-success, .os-danger, .os-hr').remove();

        if (openstock_dependant_options === '1') {
            if (that) {
                var chosen = $(that).val();
            } else {
                var chosen = '';
            }

            if ($(that).find(':checked').hasClass('os-hidden') || $(that).hasClass('os-hidden')) {
                $('.option-choice option:selected, .option-choice:checked').each(function() {
                    if (chosen !== $(this).val()) {
                        $($(this).parent()).prop('selectedIndex', 0);
                        $(this).prop('checked', false);
                    }

                    if ($('.option-choice').length === 1) {
                        $($(this).parent()).prop('selectedIndex', 0);
                        $(this).prop('checked', false);
                    }
                });
            }

            $.ajax({
                type: 'POST',
                url: 'index.php?route=extension/module/openstock/option',
                dataType: 'json',
                data: $('input[name=\'product_id\'], #product input[type=\'radio\']:checked, #product select'),
                success: function(data) {
                    for (var i = 0; i < data.hide.length; i++) {
                        $('.option-choice option[value=' + data.hide[i] + ']').addClass('os-hidden');
                        $('.option-choice[value=' + data.hide[i] + ']').addClass('os-hidden');
                        $('.option-choice[value=' + data.hide[i] + ']').parent('label').addClass('os-hidden');

                        $('.option-choice option:selected, .option-choice:checked').each(function() {
                            if ($(this).val() === data.hide[i]) {
                                $($(this).parent()).prop('selectedIndex', 0);
                                $(this).prop('checked', false);
                            }
                        });
                    }

                    for (var i = 0; i < data.show.length; i++) {
                        $('.option-choice option[value=' + data.show[i] + ']').removeClass('os-hidden');
                        $('.option-choice[value=' + data.show[i] + ']').removeClass('os-hidden');
                        $('.option-choice[value=' + data.show[i] + ']').parent('label').removeClass('os-hidden');
                    }

                    getVariant();
                }
            });
        } else {
            getVariant();
        }
    }

    function getVariant() {
        var option_ids = [];
        $('.option-choice option:selected, .option-choice:checked').each(function() {
            if ($(this).val() != '') {
                option_ids.push($(this).val());
            }
        });

        if (option_ids.length == $('#option-numbers').val()) {
            $.ajax({
                type: 'POST',
                url: 'index.php?route=extension/module/openstock/variant',
                dataType: 'json',
                data: {
                    ids: option_ids,
                    product_id: '<?php echo $product_id; ?>'
                },
                beforeSend: function() {
                    $('.os-success, .os-danger, .os-hr').remove();
                    $('#product').before('<hr class="os-hr"><div class="os-loading"><i class="fa fa-circle-o-notch fa-spin"></i> <?php echo $text_checking_options; ?></div>');
                    $('.os-price').html('').hide();
                },
                success: function(data) {
                    setTimeout(function() {
                        if (data.error) {
                            $('.os-loading').removeClass('os-loading').addClass('os-danger').empty().text(data.error);
                            $('#product-cart').hide();
                            return;
                        }

                        if (data.data.sku) {
                            $('.os-model').text('<?php echo $text_model; ?> '+data.data.sku);
                        } else {
                            $('.os-model').text('<?php echo $text_model; ?> <?php echo $model; ?>');
                        }

                        string_price = '';

                        if (!data.data.special) {
                            string_price += '<li class="product-price">'+data.data.price+'</li>';
                        } else {
                            string_price += '<li class="price-old">'+data.data.price+'</li>';
                            string_price += '<li class="price-new">'+data.data.special+'</li>';
                        }

                        string_price += '<?php if ($tax) { ?><li><?php echo $text_tax; ?> '+data.data.tax+'</li><?php } ?>';

                        string_discount = '';
                        if (data.data.discount) {
                            string_discount = '<li><hr></li>';

                            $.each(data.data.discount, function(key, discount) {
                                string_discount += '<li>'+discount.quantity+'<?php echo $text_discount; ?>'+discount.price;
                            });
                        }

                        if (data.success) {
                            $('.os-loading').removeClass('os-loading').addClass('os-success').empty().html('<i class="fa fa-check-circle"></i> '+data.success);
                            $('.product-info .price').html(string_price + string_discount).show();
                            $('#product-cart').show();
                        }

                        if (data.nostock) {
                            $('.os-loading').removeClass('os-loading').addClass('os-danger').empty().html('<i class="fa fa-exclamation-circle"></i> '+data.nostock);
                            $('.product-options .price').html(string_price).append(string_discount).show();

                            if (data.nostockcheckout == 1) {
                                $('#product-cart').show();
                            } else {
                                $('#product-cart').hide();
                            }
                        }

                        if (data.notactive) {
                            $('.os-loading').removeClass('os-loading').addClass('os-danger').empty().html('<i class="fa fa-exclamation-circle"></i> '+data.notactive);
                            $('.os-price').html(string_price).append(string_discount).show();
                            $('#product-cart').hide();
                        }

                        if (data.data.image != '') {
                            $('.os-image-main a img').attr('src', data.data.thumb);
                            $('.os-image-main a').attr('href', data.data.pop);
                        } else {
                            $('.os-image-main a img').attr('src', original_thumb);
                            $('.os-image-main a').attr('href', original_pop);
                        }
                    }, 500);
                }
            });
        }
    }

    <?php if ($openstock_show_default_price == '0') { ?>
        $(function() { $('.os-price').html('').hide(); });
    <?php } ?>

    //--></script>
<?php } ?>
]]></add>
        </operation>
    </file>
</modification>

Newbie

Posts

Joined
Sun Feb 18, 2018 2:06 am
Who is online

Users browsing this forum: No registered users and 4 guests