Author Topic: Product Automatic Expiration  (Read 2556 times)

saviB

  • Jr. Member
  • **
  • Posts: 187
Product Automatic Expiration
« on: February 13, 2013, 18:19:30 pm »
Hi Folks. Is there a way to make VM products expire? Not an auction, not a coupon, the products themselves. I know there is an availability date - but not expiration. Why would I want this? I have a client that sells workshops (speaking engagements). Because VM is so easy to use, we are setting up each engagement as a product. In other words, a product may be EVENT NAME + February 4. Of course, after Feb 4 passes - the product should terminate automatically.

It seems like a pretty straight forward and useable addition to the VM product editor.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27480
  • Always on vacation
    • Jenkin Hill Internet
Re: Product Automatic Expiration
« Reply #1 on: February 14, 2013, 17:10:40 pm »
Not seen anybody else request this, but maybe you could ask for devopment quotes on http://forum.virtuemart.net/index.php?board=18.0 or http://jobs.virtuemart.net/

You can remove price & add to cart button from a product using the price expiry date on the Product pricing panel of the product information page on VM2.0.18a. That prevents anyone "buying" it after that date.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

PolishedGeek

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 263
  • Joomla! Innovation Refined.
    • Polished Geek, LLC - Joomla! extensions, web development & custom integrations
Re: Product Automatic Expiration
« Reply #2 on: February 14, 2013, 17:25:56 pm »
As Jenkinhill says, this could certainly be achieved with a customization. I have an idea of how it could be done without any hacks to VM2, which is always an important consideration. If you decide to hire a professional developer to handle this for you, keep us in mind. We do a lot of custom VM extensions, integration and custom development. If you post on the commercial boards that Jenkinhill suggests, please do post the link here so we can take the conversation to the other board. Thanks!   
~ Deb Cinkus, CEO
Polished Geek, LLC   |    www.PolishedGeek.com

Creators of JoomLister - eBay Lister for Joomla!

djold

  • Beginner
  • *
  • Posts: 8
Re: Product Automatic Expiration
« Reply #3 on: October 07, 2016, 10:29:45 am »
You can remove price & add to cart button from a product using the price expiry date on the Product pricing panel of the product information page on VM2.0.18a. That prevents anyone "buying" it after that date.
[/quote]

Hi Kelvyn!

The 'Add to cart' button does not dissapear, only the price. So the customer could by the product at price 0 $ for instance.
I wondering that it could be hacking to make a sublayout. (I need this possibility only on product_horizon layout.)
Can You tell me how can I reference to the product price expire date in array $viewData['???'] ?

Best Regards,
Gyula

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8962
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Product Automatic Expiration
« Reply #4 on: October 07, 2016, 10:59:51 am »
add a snippet of code in the template to test if the exp date is passed.. if so hide the add to cart
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27480
  • Always on vacation
    • Jenkin Hill Internet
Re: Product Automatic Expiration
« Reply #5 on: October 07, 2016, 12:01:34 pm »
The template system in VM3 is different from that in VM2. The clue is that this thread is 3.5 years old!
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

djold

  • Beginner
  • *
  • Posts: 8
Re: Product Automatic Expiration
« Reply #6 on: October 07, 2016, 12:36:59 pm »
I using the latest version of VM 3.0.18. Is there a solutuion already? Maybe a plugin or something?

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8962
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Product Automatic Expiration
« Reply #7 on: October 07, 2016, 14:36:09 pm »
I know of no plugin..
but this is the solution

add a snippet of code in the template to test if the exp date is passed.. if so hide the add to cart
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

djold

  • Beginner
  • *
  • Posts: 8
Re: Product Automatic Expiration
« Reply #8 on: October 10, 2016, 21:35:30 pm »
Thank You the good idea. I made a script, but not inside the template.
With mysqli queries I cheking virtuemart_product_prices table and within product_price_publish_down field. If it is older than actual date, product became unpublished.
Finally with crontab I can execute it every day. (I need unpublish daily foods after p.m. 3h.)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8962
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Product Automatic Expiration
« Reply #9 on: October 10, 2016, 22:13:22 pm »
good solution
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

djold

  • Beginner
  • *
  • Posts: 8
Re: Product Automatic Expiration
« Reply #10 on: October 11, 2016, 10:22:46 am »
If somebody faceing the same problem, here is my code:
(You should insert the proper username, password and dbname of course.)

Code: [Select]
<?php
$servername 
"localhost";
$username "???";
$password "???";
$dbname "???";

// Create connection
$conn mysqli_connect($servername$username$password$dbname);
// Check connection
if (!$conn) {
    die(
"Connection failed: " mysqli_connect_error());
}

$sql "SELECT virtuemart_product_id, product_price_publish_down FROM cm42j_virtuemart_product_prices";
$result mysqli_query($conn$sql);
$current_date date("Y-m-d h:i:s");

while(
$row mysqli_fetch_assoc($result)) {
if ($row["product_price_publish_down"] <= $current_date) {
  $id $row["virtuemart_product_id"];
  
  $sql_2 "UPDATE cm42j_virtuemart_products SET published = '0' WHERE virtuemart_product_id = $id";
  $result_2 mysqli_query($conn$sql_2);
}
}

mysqli_close($conn);
?>