Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Hide Wishlist Or Add To Cart Button? Rate Topic   - - - - -

 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 31 March 2019 - 11:24 AM #1

Hide Wishlist  and  add to cart button after a user adds a product to wishlist or to their cart?

 

for example:

 

{if user adds item "A" to cart}

add to cart button for item "A" hide for that user only

{/if}



 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 853 posts

Posted 31 March 2019 - 11:31 AM #2

Hello.

 

You can check in the session if the customer has a product in the basket and then use the hook to block the show of these buttons.

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl

 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 31 March 2019 - 06:52 PM #3

What's the php code for this?

i tried the below code and it didn't work..

if (!isset($cart['products'][$_id])) {

}



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19693 posts

Posted 01 April 2019 - 05:40 AM #4

What's the php code for this?

i tried the below code and it didn't work..

if (!isset($cart['products'][$_id])) {

}

 

Looks correctly. Where did you add this code??


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 01 April 2019 - 10:51 PM #5

Looks correctly. Where did you add this code??

I added it to the smarty function and then assigned a true or false statement yet no lock..

 

 

I tried this.. on the smarty function

<?php
function smarty_function_cart_hide($params, &$smarty) {
if (!isset($cart['products'][$_id])) {
$smarty->assign('cart_added', false);
} else {
$smarty->assign('cart_added', true);
}
 
then on the tpl i used
{cart_hide}
{if $cart_added}<button>Add to Cart</button>{else}<a>view in your cart</a>{/if}
 
....yet no luck...


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11363 posts

Posted 02 April 2019 - 12:11 AM #6

And so how would a customer update product options for the item or change the quantity?  Going to force them to go to the cart to do this?


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 02 April 2019 - 03:01 AM #7

And so how would a customer update product options for the item or change the quantity?  Going to force them to go to the cart to do this?

 

 

I'm hoping that if someone can help me figure it out, when a customer select a different option the add to cart should reappear, just like on ebay...



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19693 posts

Posted 02 April 2019 - 05:16 AM #8

Your code will not work since $cart and $_id are not passed to your function. Please also note that $_id parameter is not ID of the product, but ID generated by the fn_generate_cart_id function. It takes into account ID, selected options and extra parameters


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 02 April 2019 - 11:36 PM #9

Your code will not work since $cart and $_id are not passed to your function. Please also note that $_id parameter is not ID of the product, but ID generated by the fn_generate_cart_id function. It takes into account ID, selected options and extra parameters

Can you help me out with a code that will do this?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19693 posts

Posted 03 April 2019 - 05:30 AM #10

Try something like

 

func.php:

function fn_check_product_in_cart($product_id) {
    $in_cart = false;
    $cart = Tygh::$app['session']['cart'];
    if (!empty($cart['products'])) {
        foreach ($cart['products'] as $product) {
            if ($product['product_id'] == $product_id) {
                $in_cart = true;        
                break;
            }
        }    
    }
    return $in_cart;
}

your template:

{$cart_added = $product.product_id|fn_check_product_in_cart}
{if !$cart_added}<button>Add to Cart</button>{else}<a>view in your cart</a>{/if}

(!) Not tested


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 03 April 2019 - 10:40 PM #11

Try something like

 

func.php:

function fn_check_product_in_cart($product_id) {
    $in_cart = false;
    $cart = Tygh::$app['session']['cart'];
    if (!empty($cart['products'])) {
        foreach ($cart['products'] as $product) {
            if ($product['product_id'] == $product_id) {
                $in_cart = true;        
                break;
            }
        }    
    }
    return $in_cart;
}

your template:

{$cart_added = $product.product_id|fn_check_product_in_cart}
{if !$cart_added}<button>Add to Cart</button>{else}<a>view in your cart</a>{/if}

(!) Not tested

Oh lord, it works!!!!!!!!!!!!!!! You the best..! Thanks, I really appreciate it! any way to get this for the wishlist button too?



 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 03 April 2019 - 11:21 PM #12

Oops it doesn't take the change option into consideration.. can you help me fix this.. Thanks



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19693 posts

Posted 04 April 2019 - 05:18 AM #13

Thanks, I really appreciate it! any way to get this for the wishlist button too?

 

Use similar function but get content wishlist with the following line

$cart = Tygh::$app['session']['wishlist'];

Oops it doesn't take the change option into consideration.. can you help me fix this.. Thanks

 

In this case more complex changes are required. You should pass selected options to the function and check it there 


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 05 April 2019 - 03:43 AM #14

How can i pass the selected option please?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19693 posts

Posted 05 April 2019 - 07:41 AM #15

Try to use

{$cart_added = $product.product_id|fn_check_product_in_cart:$product.selected_options}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 05 April 2019 - 10:54 PM #16

 

Try to use

{$cart_added = $product.product_id|fn_check_product_in_cart:$product.selected_options}

 

i tried it, but it didn't change back to add to cart when option is changed.. 



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19693 posts

Posted 08 April 2019 - 06:14 AM #17

As I said, more complex changes are required


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 11 April 2019 - 03:06 AM #18

I tried to the below code, can you please give a tweak, thanks

 

 

 

        if (!empty($cart['products']) && is_array($cart['products'])) {
            $product_not_in_cart = true;
            foreach ($cart['products'] as $k => $v) {
                // Check if the product with the same selectable options already exists ( for tracking = O)
                if ($k != $cart_id) {
                    if (isset ($product['tracking']) &&
                        (
                            $product['tracking'] == ProductTracking::TRACK_WITHOUT_OPTIONS &&
                            $v['product_id'] == $product_id
                        ) ||
                        (
                            $product['tracking'] == ProductTracking::TRACK_WITH_OPTIONS &&
                            @$v['selectable_cart_id'] == $selectable_cart_id
                        )
                    ) {
                        $current_amount -= $v['amount'];
                    }
                } else {
                    $product_not_in_cart = false;
                }
            }


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19693 posts

Posted 11 April 2019 - 05:50 AM #19

This code will not work correctly. Hire someone to create required functions for you


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Dexterflamez
  • Advanced Member
  • Trial users
  • Join Date: 08-Jan 18
  • 77 posts

Posted 11 April 2019 - 10:34 PM #20

I just sent you a direct message, added to that i want the options to save on the product page as well... Thanks