If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / How do u set up zen to automatically delete a downloadable product after the sale?

How do u set up zen to automatically delete a downloadable product after the sale?

Started by oneaday on 19 Mar 2011, 1:51 AM · Views: 2,403

Results 1 to 14 of 14
19 Mar 2011, 1:51 AM
#1
oneaday avatar

oneaday

New Zenner

Join Date:
Mar 2011
Posts:
5
Plugin Contributions:
0

How do u set up zen to automatically delete a downloadable product after the sale?

Hello all,

I've searched everywhere and can't find the answer...hopefully someone can help out.

I'm trying to set up a site to sell a downloadable product which after struggling to get that set up finally seems to work but...

The product is a PDF that is sold only once to one customer then the ad would be automatically deleted from the system.

I thought by setting the "Products Quantity" to "1" would make it become unavailable to everyone else after the sale transaction occurred. Apparently this is not the way as the product is still available and even shows a quantity of "1" after the sale.

So can someone pleeeease tell me how to have zen cart automatically delete an ad for a one-time downloadable PDF product after it is sold.

Thanks in advance,
Ivan

19 Mar 2011, 2:27 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How do u set up zen to automatically delete a downloadable product after the sale?

Check your settings in

admin > config > stock

Zen-Venom Get Bitten

19 Mar 2011, 3:00 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: How do u set up zen to automatically delete a downloadable product after the sale?

I understand downloadable products are excluded from stock checking. You could change that in the code...

19 Mar 2011, 5:51 AM
#4
oneaday avatar

oneaday

New Zenner

Join Date:
Mar 2011
Posts:
5
Plugin Contributions:
0

Re: How do u set up zen to automatically delete a downloadable product after the sale?

Thanks for your responses.

So how would I change the code to automatically not show in the catalog after 1 download?

19 Mar 2011, 6:41 AM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How do u set up zen to automatically delete a downloadable product after the sale?

In a stock install with the demo products and stock control enabled I set the stock to "0" for this item and you can view the result **HERE**

Zen-Venom Get Bitten

19 Mar 2011, 12:46 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do u set up zen to automatically delete a downloadable product after the sale?

You would need to customize the order.php class so that when the Download is processed, it is done so like a regular product ...

The code currently processes differently for normal Products and Download Products:

          if ((DOWNLOAD_ENABLED != 'true') || $stock_values->fields['product_is_always_free_shipping'] == 2 || (!$stock_values->fields['products_attributes_filename']) ) {
            $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
            $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Mar 2011, 12:32 AM
#7
oneaday avatar

oneaday

New Zenner

Join Date:
Mar 2011
Posts:
5
Plugin Contributions:
0

Re: How do u set up zen to automatically delete a downloadable product after the sale?

I tried playing with the stock settings (admin > config > stock) and that doesn't seem to automatically make the download unavailable after 1 download. Unless I did something wrong with this can someone explain how to do it this way?

I guess I could set the stock to "0" but that wouldn't work because that would be manually doing it and if I'm out in the field away from a computer I wouldn't be able to update it fast enough where another customer could order the download a second time and the business model would fail.

The change in the code seems like an option but what exactly would I change it to in that code so zen cart will automatically only allow just one download of the pdf i'm trying to sell? I'm decent at html but php is chinese to me.

If anyone has answers please help.

Thanks

22 Mar 2011, 4:23 AM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: How do u set up zen to automatically delete a downloadable product after the sale?

Stock settings are not going to do the job for you. The code change is not "an" option, it is the only option.
I'm not familiar with this chunk of code, but my take on it would be that you could comment out the parts in red (with comment marks as shown).```
if (/(DOWNLOAD_ENABLED != 'true') ||/ $stock_values->fields['product_is_always_free_shipping'] == 2 /|| (!$stock_values->fields['products_attributes_filename'])/ ) {
$stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
} else {
$stock_left = $stock_values->fields['products_quantity'];
}

22 Mar 2011, 4:43 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do u set up zen to automatically delete a downloadable product after the sale?

To make it always reduce stock you would be better off with:

          if (true || (DOWNLOAD_ENABLED != 'true') || $stock_values->fields['product_is_always_free_shipping'] == 2 || (!$stock_values->fields['products_attributes_filename']) ) {
            $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
            $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
          } else {
            $stock_left = $stock_values->fields['products_quantity'];
          }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Mar 2011, 7:57 AM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: How do u set up zen to automatically delete a downloadable product after the sale?

As I looked at it, I had the suspicion that all three of the tests were for downloadables, but didn't get to confirming the purpose of the middle one. Always best to get the simplest way of making changes from one who knows:)

22 Mar 2011, 11:15 PM
#11
oneaday avatar

oneaday

New Zenner

Join Date:
Mar 2011
Posts:
5
Plugin Contributions:
0

Re: How do u set up zen to automatically delete a downloadable product after the sale?

I went with adding true || to the code and it seems to be just the ticket. Thanks everyone for your help.

23 Mar 2011, 1:16 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do u set up zen to automatically delete a downloadable product after the sale?

Thanks for the update that this is now working for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

3 Oct 2011, 6:47 AM
#13
hmartens avatar

hmartens

New Zenner

Join Date:
Sep 2011
Posts:
5
Plugin Contributions:
0

Re: How do u set up zen to automatically delete a downloadable product after the sale?

Ajeh:

To make it always reduce stock you would be better off with:

      if (true || (DOWNLOAD_ENABLED != 'true') || $stock_values->fields['product_is_always_free_shipping'] == 2 || (!$stock_values->fields['products_attributes_filename']) ) {
        $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
        $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
      } else {
        $stock_left = $stock_values->fields['products_quantity'];
      }

Thanks Linda...it worked beautifully! I just changed the code to what you said and Voila! it works! Thanks so much for your help...
3 Oct 2011, 1:22 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do u set up zen to automatically delete a downloadable product after the sale?

Thanks for the update that this is working for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!