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.
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.
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!
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
add a snippet of code in the template to test if the exp date is passed.. if so hide the add to cart
The template system in VM3 is different from that in VM2. The clue is that this thread is 3.5 years old!
I using the latest version of VM 3.0.18. Is there a solutuion already? Maybe a plugin or something?
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
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.)
good solution
If somebody faceing the same problem, here is my code:
(You should insert the proper username, password and dbname of course.)
<?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);
?>