Page 1 of 1
elegant way needed to show (and buy) products with status = 0 (on special circumstances)
Posted: Tue Jun 14, 2022 6:52 pm
by loop
Hi All
i need a way to can show on product_info.php a products_id which is status = 0 (on a special circumstances, for example if they come with a special link / Parameter)
i can make in the product_info.php this, but the "$products" object / array is not really filled whenn status=0 so i get errors on every corner. So i need to have a better way / hook maybe to do that, can anybody point me to the right direction?
Code: Select all
if((!empty($_GET['ad']) && strpos($_GET['ad'],Speciallink_') > -1)||(!empty($advertiser) && strpos($advertiser,'Speciallink_') > -1)){
$show_status_red = "";
}else{
$show_status_red = "p.products_status = '1' and";
}
$product_info_query = tep_db_query("SELECT p.*, pd.* FROM products p, products_description pd where ".$show_status_red." p.products_id = " . (int)$_GET['products_id'] . " and pd.products_id = p.products_id and pd.language_id = " . (int)$languages_id);
Re: elegant way needed to show (and buy) products with status = 0 (on special circumstances)
Posted: Tue Jun 14, 2022 7:34 pm
by burt
It's a difficult concept, as status = 0 means (for most shopowners) the product is unavailable, but may come back at some later date.
I'd probably make a new product_info page to display these particular products.
EG product_discontinued.php [or whatever name you think up]
In this page simply show products where p.products_status = 0 [as you would not want your live products showing on this particular page.
Conceptual difficulties.
Will the breadcrumb work?
Will the (hidden) product data work? EG twitter stuff, opengraph, etc
Will the customer be able to add a status=0 product to cart?
Will the checkout work?
It's all unknown, as no one (I think) will have used the products_status in this way.
My advice would be to set up a new product displaying page to at least get a status=0 product showing, and then further test things from there...
Re: elegant way needed to show (and buy) products with status = 0 (on special circumstances)
Posted: Tue Jun 14, 2022 8:09 pm
by Kofod95
I might investigate something similar with the working-title: Pseudo products.
This is intended for plastic bags and special gift wrapping items to offer on the shopping cart.
As Burt, I would think using product info may be too much wrestling with intended behavior, so a new page for that would likely be easier. You may be able to pull the product info layout anyway, and maybe even create the product as normal. I just noticed this check:
https://github.com/CE-PhoenixCart/Phoen ... id.php#L33. Not sure how to implement, but seems possible
//Daniel
Re: elegant way needed to show (and buy) products with status = 0 (on special circumstances)
Posted: Tue Jun 14, 2022 9:35 pm
by ecartz
To fetch a product with status 0, try
Code: Select all
class hook_shop_product_info_ad {
public function listen_siteWideStart() {
if (!isset($GLOBALS['product']) && !empty($_GET['ad') && (strpos($_GET['ad'], 'Speciallink_') !== false)) {
$GLOBALS['product'] = product_by_id::administer($_GET['products_id']);
$GLOBALS['product']->set('status', '1');
}
}
}
But it might be easier to work from the other end. Instead of making the product status 0, put something else in that tells you that when ad is not set, make the product unbuyable. That's two hooks. One that blocks add_to_cart on unbuyable products and another that blocks checkout or the cart_order_builder on unbuyable products. If you put a hook in checkout, you might have it replace the stock check.
Re: elegant way needed to show (and buy) products with status = 0 (on special circumstances)
Posted: Wed Jun 15, 2022 5:14 am
by Kofod95
For ecartz' proposal I have something similar I know I need to do, though I will not hide the products completely, only their buttons.
If I get to it before you, I'll gladly assist you with the experience gained from that!
//Daniel
Re: elegant way needed to show (and buy) products with status = 0 (on special circumstances)
Posted: Wed Jun 15, 2022 12:14 pm
by loop
thank you all!
Good points, and i already implemented it with the ideas given. I made a addititional field in products called products_visible (standard = 1)
if i change the field to 0 it's not anymore in the queries i have in index.php and in search. but with the direct link to the product you can see it normaly and buy it normaly. So it's a "hidden" product which is normal handled as soon as it's found. for me it's perfect. The only thing i had to adjust alot of queries where "products_statuts = 1" its now "products_visible = 1 and products_status = 1"
thank you all for the perfect help / support