hikashop module

  • Posts: 55
  • Thank you received: 0
3 months 2 weeks ago #290581

i developed a module for hikashop product view but there is problem. i don't know how to force the module to follow hikashop configuration rules.
in hikashop configuration i choose when "add to cart" clicked "stay on same page and show a pop up", but this module go to checkout directly. how can i fix this ?
is there any block of code to do that ?
regard

Last Edit: 3 months 2 weeks ago by ebrahimahamdi.

Please Log in or Create an account to join the conversation.

  • Posts: 22520
  • Thank you received: 3509
  • MODERATOR
3 months 1 week ago #290582

Hello,

Please provide your HikaShop version number.
Also, please note that you're talking about legacy settings.
www.hikashop.com/support/documentation/5...html#advanced_legacy

Regards


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 55
  • Thank you received: 0
3 months 1 week ago #290652

hikashop version is 3.3
and the legacy setting is off.
would you tell where and how to use fallback functions.
it is my default module file :
how can implement the fallback function and use it here

<?php

defined('_JEXEC') or die('Restricted access');

if(!empty($products)) :
?>
<div class="hikashop_tglproducts_module<?php echo $moduleclass_sfx; ?>" id="hikashop_tglproducts_module">

    <div class="row">

        <?php foreach ($products as $product): ?>

        <div class="product-item col bg-white mx-1 p-2" id="product-<?php echo $product['product_id']; ?>">

            <div class="product-img">
                <img class="img-fluid" src="<?php echo $product['image']; ?>" alt="<?php echo $product['product_name']; ?>" />
            </div>

            <form class="form pt-2">

                <div class="form-group row mb-2">
                    <label for="" class="col-sm-6 col-form-label"><?php echo $product['product_name']; ?></label>
                    <div class="col-sm-6">
                        <select class="form-control custom-select product-charactgleristic">
                            <?php $first = true; foreach ($product['characteristic'] as $ccItem): ?>

                            <option value="<?php echo $ccItem['id']; ?>" data-pid="<?php echo $ccItem['pid']; ?>" data-amount="<?php echo $ccItem['amount']; ?>" <?php if($first) {$first = false; echo 'selected="selected"'; } ?>>
                                <?php echo $ccItem['alias']; ?>
                            </option>

                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>

                <div class="lead text-center pb-2 product-price">
                    <?php echo $currency->format((isset($product['characteristic'][0]['amount']) ? $product['characteristic'][0]['amount'] : 0), hikashop_getCurrency()); ?>
                </div>

                <div class="form-group row">
                    <div class="input-group col-sm-12">
                        <div class="input-group-append product-qinc">
                            <span class="input-group-text">+</span>
                        </div>
                        <input type="text" class="form-control text-center product-quantity" placeholder="<?php echo JText::_('MOD_HIKASHOP_TGLPRODUCTS_COUNT'); ?>" value="1">
                        <div class="input-group-prepend product-qdec">
                            <span class="input-group-text">-</span>
                        </div>
                    </div>
                </div>

  <a class="btn btn-block hikabtn hikacart tglproduct_addtocart" href="index.php/component/hikashop/product/updatecart/add-1/cid-<?php echo (isset($product['characteristic'][0]['pid']) ? $product['characteristic'][0]['pid'] : $product['product_id']); ?>/quantity-1"><?php echo JText::_('MOD_HIKASHOP_TGLPRODUCTS_ADD_TO_CART'); ?></a>
            </form>
        </div>

        <?php endforeach; ?>

    </div>

</div>

<script>	
    jQuery(document).ready(function () {
        // Get currency
        var priceFormat = '<?php echo $currency->format(0, hikashop_getCurrency()); ?>';
        var priceFormatParts = priceFormat.trim().split(' ');
        var currency = priceFormatParts.pop();

        var baseAddLink = 'index.php/component/hikashop/product/updatecart/add-1/';

        jQuery('.product-qinc').click(function () {
            var productQuantityField = jQuery(this).parent().children('input.product-quantity');
            productQuantityField.val(parseInt(productQuantityField.val()) + 1);

            createAddLink(this);
        });

        jQuery('.product-qdec').click(function () {
            var productQuantityField = jQuery(this).parent().children('input.product-quantity');
            productQuantityField.val(parseInt(productQuantityField.val()) - 1);

            createAddLink(this);
        });

        jQuery('.product-charactgleristic').change(function () {
            var amount = jQuery("option[value=" + jQuery(this).val() + "]", this).attr('data-amount');
            // change amount
            jQuery(this).parents('form').children('.product-price').html(amount + ' ' + currency);

            createAddLink(this);
        });

        function createAddLink(currentPosition) {
            var productParent = jQuery(currentPosition).parents("div[id^='product-']");
            var pid = productParent.find('select.product-charactgleristic').find("option:selected").attr('data-pid');
            var quantity = productParent.find('input.product-quantity').val();
            var propString = 'cid-' + pid + '/quantity-' + quantity;
            productParent.find('a.tglproduct_addtocart').attr('href', baseAddLink + propString);
        }
    });
</script>

<?php endif;

Please Log in or Create an account to join the conversation.

  • Posts: 62706
  • Thank you received: 8985
  • MODERATOR
3 months 1 week ago #290666

Hi,

If you want to use the direct add to cart URL and not the javascript functions HikaShop provides, then you need to add an extra "url" parameter to your add to cart URL with the URL where you want to be redirected to after the add to cart process. The URL you add as value of that parameter needs to be urlencoded.

Please Log in or Create an account to join the conversation.

Time to create page: 0.081 seconds
Powered by Kunena Forum