Page 1 of 1

OpenCart Catalog mode, unregistered users?

Posted: Mon Jul 08, 2019 4:46 pm
by okli
Hi All,
Can someone help me to find a solution.

When the user is not registered and login.
Must see only products, no to show the price in product and category and cart button to hide.

When the user is login.
Can see everything normally, product prices and cart button.

Only registered and lodged users to see price and can make an order!

Do you know someone extension to make this? I try to find it but nothing.
Open Cart version is 2.3.0.2

Re: OpenCart Catalog mode, unregistered users?

Posted: Mon Jul 08, 2019 5:07 pm
by cyclops12
Isn't there a setting in admin to not show prices if not logged in ?

Re: OpenCart Catalog mode, unregistered users?

Posted: Mon Jul 08, 2019 5:27 pm
by OSWorX
cyclops12 wrote:
Mon Jul 08, 2019 5:07 pm
Isn't there a setting in admin to not show prices if not logged in ?
Correct: Menu Settings > Tab Options >> Section Account : Show prices only to logged in (or like this in english)

Re: OpenCart Catalog mode, unregistered users?

Posted: Mon Jul 08, 2019 5:53 pm
by okli
Yes, I found it. Thank you

I found a solution for the cart button, works great for me but can't make it in ocmod.

I Add this code manually in the header.tpl file.

Code: Select all

<?php if($logged) {  ?>
...my shopping cart code
<?php } ?>
And Works fine.

I Add this code with ocmod file, but not working, any ideas about how to debug code?

Code: Select all

<modification>

    <file path="catalog/view/theme/{so-mobile,so-revo}/template/header/header1.tpl">
        <operation error="skip">
            <search><![CDATA[<div class="block-cart">
                                <div class="shopping_cart">
                                    <?php echo $cart; ?>
                                </div>
                            </div>]]></search>
            <add position="before"><![CDATA[<?php if($logged) {  ?>]]></add>
        </operation>
    </file>

    <file path="catalog/view/theme/{so-mobile,so-revo}/template/header/header1.tpl">
        <operation error="skip">
            <search><![CDATA[<div class="block-cart">
                                <div class="shopping_cart">
                                    <?php echo $cart; ?>
                                </div>
                            </div>]]></search>
            <add position="after"><![CDATA[<?php } ?>]]>
            </add>
        </operation>
    </file>

</modification>
I Want to make with ocmod file, not with hardcode.

Re: OpenCart Catalog mode, unregistered users?

Posted: Mon Jul 08, 2019 8:36 pm
by OSWorX
This code wil never work.
1.
not

Code: Select all

<file path="catalog/view/theme/{so-mobile,so-revo}/template/header/header1.tpl">
instead

Code: Select all

<file path="catalog/view/theme/*/template/header/header1.tpl">
or if you want to change a specific file only, name only that

2. wrong

Code: Select all

<search><![CDATA[<div class="block-cart">
                                <div class="shopping_cart">
                                    <?php echo $cart; ?>
                                </div>
                            </div>]]></search>
you can search only for one line (or use regex):

Code: Select all

<?php echo $cart; ?>
3. why so complicated?
Use the enclosed mod, try it and report back.