Post by designlabs » Sat Mar 03, 2012 6:07 pm

Hello,

I have been trying to think on a particular thought, if i could restrict my clients to some particular number of products that they could add. Once they are reaching the same, maybe a notification or a bar showing the number or products added.

Is this possible.

Newbie

Posts

Joined
Mon Jul 04, 2011 4:58 pm

Post by Johnathan » Sat Mar 03, 2012 7:40 pm

Any reason for doing this? I don't really see an advantage to restricting the number of products.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by designlabs » Sat Mar 03, 2012 7:59 pm

Got a requirement. hence posted the same.

Newbie

Posts

Joined
Mon Jul 04, 2011 4:58 pm

Post by Johnathan » Sat Mar 03, 2012 11:58 pm

Ah, got it. It would probably be easiest to just hide the "Insert" button when there are a certain number of products. You should be able to do it with something like this:

Code: Select all

IN:
/admin/view/template/catalog/product_list.tpl

REPLACE:
<a onclick="location = '<?php echo $insert; ?>'" class="button"><?php echo $button_insert; ?></a>

WITH:
<?php $this->load->model('catalog/product'); if ($this->model_catalog_product->getTotalProducts() <= 20) { ?>
<a onclick="location = '<?php echo $insert; ?>'" class="button"><?php echo $button_insert; ?></a>
<?php } ?>
Replace "20" with whatever number you need.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by designlabs » Sun Mar 04, 2012 12:08 am

Hello,

Yes this would be a easy way on this. A more practical approach it is. Thanks for this. However as a customer when I think, suppose if we were to forget that this setting is done. Then it could be mistaken for an error. I suggest a small thing as well to add up. A count of products added beside the insert button. Hence when I see 20 of 20 shown then, then any layman would understand the limit is set.

Any idea on what code we need to set in to show the counter of added products to the number of allowed products. What's your opinion.

Do let me know if this can be done.

Newbie

Posts

Joined
Mon Jul 04, 2011 4:58 pm

Post by Johnathan » Sun Mar 04, 2012 12:28 am

Just take the value returned by $this->model_catalog_product->getTotalProducts(), and subtract it from the value you want, then display it next to the button.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by designlabs » Sun Mar 04, 2012 12:38 am

Thanks for ur answer.. However I am not a programmer bro.. Just a designer. Till now was just designing and integrating the cart. However had a peculiar request and I was stuck. Is it possible for you to tell me what could be the code. And also let me know ur skype I'd. Maybe customization projects I could send it across. What say. Could u help me with this for now.

Newbie

Posts

Joined
Mon Jul 04, 2011 4:58 pm

Post by Johnathan » Sun Mar 04, 2012 1:37 am

Unfortunately I'm already overbooked with work, so I don't have time for any new projects. I recommend you post a request in the Commercial Support forum, where you might find some takers for projects.

Best of luck

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by designlabs » Sun Mar 04, 2012 2:36 am

hey thats cool.. but thanks for your help.. really appreciate the same..

Newbie

Posts

Joined
Mon Jul 04, 2011 4:58 pm

Post by wappdesign » Sun Apr 15, 2012 4:19 pm

I was looking for the same thing. Based on the comments in this thread I made an vqmod extension:

http://www.opencart.com/index.php?route ... on_id=5973

Newbie

Posts

Joined
Sun Apr 15, 2012 4:17 pm

Post by usersk » Wed May 30, 2018 5:43 am

I have problem to make work this in opencart 3.0.20 , I need your help, thanks!

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <file path="admin/controller/catalog/product.php">
        <operation>
            <search><![CDATA[
            $product_total = $this->model_catalog_product->getTotalProducts($filter_data);
            ]]></search>
            <add position="after"><![CDATA[
            $data['br_produkti'] = $this->model_catalog_product->getTotalProducts($filter_data);
            ]]></add>
        </operation>
    </file>

<file path="admin/view/template/catalog/product_list.twig">
	<operation>
	<search><![CDATA[
	<a href="{{ add }}" data-toggle="tooltip" title="{{ button_add }}" class="btn btn-primary"><i class="fa fa-plus"></i></a>
	]]></search>
	<add position="replace"><![CDATA[
		<?php if ($br_produkti<a href="{{ add }}" data-toggle="tooltip" title="{{ button_add }}" class="btn btn-primary"><i class="fa fa-plus"></i></a>
	]]></add>
	</operation>
</file>

	
</modification>

Newbie

Posts

Joined
Thu Apr 12, 2018 8:15 pm
Who is online

Users browsing this forum: No registered users and 37 guests