Post by Joe1234 » Sun Jan 23, 2022 5:51 pm

Is there some type of extension that if customer "A" has a product in their cart or wishlist, something can be displayed on the product page --in details or something-- that another customer has the product on in their cart or wishlist? Or a second option if customer "B" then adds the same product to their cart or wishlist they get a notification that another customer has done the same? This to encourage someone to hurry up and buy, my store is made up of single inventory products.

Thanks.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by DigitCart » Sun Jan 23, 2022 6:26 pm

​Hi

Take a look at my extension:
Just Purchased Notifications And More (Real Time Notifications)

https://www.opencart.com/index.php?rout ... n_id=35052

Please check its live demo.​

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by Joe1234 » Mon Jan 24, 2022 3:01 am

Not exactly what I'm looking for. This looks like a general notification of actions...if I'm not mistaken. Which is too broad. I'm looking for something more targeted to the particular item someone might be browsing. So if customer A added mac1 to their cart/wishlist and customer B went to mac1 page, at that time only customer B would be informed that someone has added mac1 to their cart/wishlist by ways of a notification or preferably an indicator right beside the "In Stock" indicator.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by Joe1234 » Mon Jan 24, 2022 3:32 am

I'm starting to think my needs is something that's going to have to be custom or I'll have to do it myself. Because I just realized if customer B hurries up and buys it, what happens to person A cart with the product already in it. They would have to get some type of notification of what happened and have it removed from their cart or wishlist before they try and checkout...or checkout would have to do an inventory check before final process.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by by mona » Mon Jan 24, 2022 10:15 am

This to encourage someone to hurry up and buy, my store is made up of single inventory products
If your store contains only unique products (one of a kind) then it would be better to include the cart contents in the product availability instead of encouraging a rat-race to checkout.

Currently the product availability is based on stock, not what is in anybodies cart.
That is somewhat strange as in a physical shop, once a customer puts a unique product in his basket nobody else can as it is off the shelf.
In OC many customers can put the same unique product in their cart as it is not taken off the shelf, whoever checks out first wins.

So basically, subtract the quantity of the product in anybodies cart from the stock quantity to obtain the availability.
Then when someone puts the product in their cart, it becomes unavailable for everybody else until that cart is discarded.

There is a problematic side-effect with this as OC retains the carts of registered customers indefinitely.
This would mean that when a registered customer puts the product in their cart, it becomes unavailable for everybody else until they remove it themselves.
Then again, retaining carts for registered customers indefinitely is a silly, confusing and unnecessary, that is what wish-lists are for.

That being said, Amazon work in exactly the same way - if there is only one product and several people have it in the cart - who ever pays first wins - just like OC Amazon keeps your cart although it works differently .. and the ONLY ONE LEFT IN STOCK is highlighted on the product page.

I believe that is sufficient in their case as there are not always only one item, so there is, having lost out once, an element of do I want it better buy it quick, I can always cancel .. so that is another thing you have to consider when making people rush to buy ..

Anyway, you could try something like this

Controller:

Code: Select all

$sql = "select SUM(quantity) as quantity from " . DB_PREFIX . "cart where session_id != '".$this->session->getId()."' and product_id = '".(int)$this->request->get['product_id']."'";
$query = $this->db->query($sql);
$data['product_cart_qty_others'] = (!empty($query->row['quantity']) ? $query->row['quantity'] : 0);
View:

Code: Select all

{% if product_cart_qty_others %}
	<li><h1>Someone else has put this product in their cart, RUN!</h1></li>
{% endif %}

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by paulfeakins » Mon Jan 24, 2022 7:59 pm

Joe1234 wrote:
Mon Jan 24, 2022 3:01 am
Not exactly what I'm looking for.
If you can't find an extension, you could pay a developer such as ourselves or post a job in the Commercial Support Forum.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by Joe1234 » Tue Jan 25, 2022 3:43 am

@by mona
I love what you put in for the display lmao. I hear all you're saying, but I think your code is the path I'd like to take. I found where I wanted to put the display, but I can't find the file or where in the file to put the database query. I put the query at the top of: /catalog/controller/journal3/product.php, and I put the display in: /catalog/view/theme/journal3/template/product/product.twig. Where should I actually put the query?

Thanks.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by Joe1234 » Thu Jan 27, 2022 10:58 pm

Anyone?

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by Joe1234 » Fri Jan 28, 2022 12:45 pm

Finally figured it out. In case anyone else is trying to just hard code something to display from the database here is a brief noob explanation since I couldn't find it anywhere else on the site.

You need to edit the 3 files associated with the page you want to display the query on (or make the files and link them), for this explanation I am using the product page.
So you'd edit:

/catalog/model/catalog/product.php (the database query page)
In this I created a function "getLiveStock" to query the database:

Code: Select all

    public function getLiveStock() {
        $sql = "select SUM(quantity) as quantity from " . DB_PREFIX . "cart where session_id != '".$this->session->getId()."' and product_id = '".(int)$this->request->get['product_id']."'";
        $query = $this->db->query($sql);
        $data['product_cart_qty_others'] = (!empty($query->row['quantity']) ? $query->row['quantity'] : 0);
        return $data['product_cart_qty_others'];
    }

/catalog/view/theme/journal3/template/product/product.twig (the display page)(the theme of your choice)
In this I checked if the function I created found what I want

Code: Select all

{% if product_cart_qty_others %}
  Some text
{% endif %}

/catalog/controller/product/product.php (the control page)
In this I put the following to get the information that was queried. "model_catalog_product" being the file and path I believe of the file the function was put in.

Code: Select all

$data['product_cart_qty_others'] = $this->model_catalog_product->getLiveStock();
AFTER:

Code: Select all

$this->load->model('catalog/product');
(the include code for the product)

Now when I have time I'll figure out how to make this into a module.
Last edited by Joe1234 on Fri Feb 04, 2022 9:29 pm, edited 6 times in total.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by Joe1234 » Fri Jan 28, 2022 12:47 pm

Now the last part, how do I include the wishlist part?

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by by mona » Fri Jan 28, 2022 1:05 pm

No one is answering because this is an Opencart Forum not a Journal Forum and whilst they tell you all the time "its opencart" it isn’t
there is no

Code: Select all

 public function getLiveStock() {
there is no

Code: Select all

{% if LiveStock %}
We do not know what is there and what isn’t there - what is Journal and what is yours - what functions they have - what they don’t
If you want assistance and you have that theme, you must ask them.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Joe1234 » Fri Jan 28, 2022 9:45 pm

Thanks for pointing out "LiveStock", I edited the post to make that a little more clear.

I'm sorry, I'm a little lost. For future reference, what does whatever theme I use have to do with a request like mine? What I wanted, did, and now need has nothing to do with a template and was put in the core files except for the display portion...still learning this. Is "Journal" a bad thing here? Do I have to hide their name (or any template name) even for things that don't concern the theme? What I would have expected was to get assistance based off base/fresh installation and then I figure out the rest based on my theme because as far as I can see my question has nothing to do with my theme, a bug, or code conflict. I don't think a wishlist query is based in Journal?

Thanks.

v3.0.3.8
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am
Who is online

Users browsing this forum: OSWorX, paulfeakins and 14 guests