Compared to the above codes, it could simply be done as a small extension with either VQMod / OCMod.
In your system/library/cart/cart.php file,
find:
add above:
Code: Select all
public function hasProduct($product_id) {
$product_data = array();
$products = $this->getProducts();
foreach ($products as $product) {
$product_data[] = (int)$product['product_id'];
}
return (in_array((int)$product_id, $product_data));
}
Then, in your catalog/controller/product/product.php file,
find:
Code: Select all
$this->model_catalog_product->updateViewed($this->request->get['product_id']);
add above:
Code: Select all
$data['product_in_cart'] = $this->cart->hasProduct($this->request->get['product_id']);
Then, in your catalog/view/theme/<your_theme>/template/product/product.twig file, you could add your conditional IF statement:
Code: Select all
{% if product_in_cart %}
...
{% else %}
...
{% endif %}
The '...' would be your condition statement, in this case, the opposite statement of the add to cart. Else, the add to cart button statement already used.