Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 11-22-2024 17:13:11

polarize
Member
Registered: 11-15-2004
Posts: 309

Favorite Items List

Is it possible to convert Wish List over to a Favorite Items list and where could we look at that? 

Essentially it works just like the Wish List except instead of moving items to the cart it should have the option to add it to cart but not delete it from the Favorites List. 

I was looking in ECOM_Cart.php to get an idea of how it functions with relation to the WISHLIST.  Is this the correct location and can we modify this to act like a Favorite Items list to keep items added in there that can be added to cart rather than moved to cart?


Code:

// +------------------------------------------------------------------+
// | Function: movecart                                               |
// +------------------------------------------------------------------+

function movecart () {

// +--
// | This function moves an item from a user's shopping cart to their
// | wish list and visa-versa.
// +--

$cart     = $this->globals('ecom.cart_contents');
$ref      = $this->globals('core.ref');
$savetype = 'CART';

foreach ($cart as $num => $cartdata) {

     if ($cartdata['offergroup'] != $ref) {continue;}

     $savetype = $cartdata['savetype'];

     if ($savetype == 'CART') {$cart[$num]['savetype'] = 'WISHLIST';}
     else                     {$cart[$num]['savetype'] = 'CART';}

} // End of foreach statement.

// +--
// | Save the cart.
// +--

$this->savecart($cart);

// +--
// | Print a message and redirect back to the cart.
// +--

$this->print_message('ecom','cartcnfmove');

if ($this->debug) {$this->debugger("movecart: Moved item '{$ref}' in user cart.");}

// +--
// | Check the cart now.
// +--

$this->check_cart();

// +--
// | Return the cart or wish list.
// +--

if   ($savetype == 'WISHLIST') {return $this->exec_namespace(array('app' => 'ecom', 'namespace' => 'viewwishlist', 'type' => '*', 'params' => null));}
else                           {return $this->exec_namespace(array('app' => 'ecom', 'namespace' => 'viewcart', 'type' => '*', 'params' => null));}

} // End of function.

Using Kryptronic K9! smile
Previous Versions:
ClickCartPro 8
ClickCartPro 7
ClickCartPro 6
ClickCartPro 5.1

Offline

 

#2 11-25-2024 09:48:20

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19850
Website

Re: Favorite Items List

Well the magic is here:

Code:

if ($savetype == 'CART') {$cart[$num]['savetype'] = 'WISHLIST';}
else                     {$cart[$num]['savetype'] = 'CART';}

So instead of changing the savetype, you want to duplicate it.  Change to:

Code:

if ($savetype == 'CART') {

     $cart[$num]['savetype'] = 'WISHLIST';

} else {

     $max = $this->globals('ecom.cart_max'); $max++; $this->globals('ecom.cart_max',$max);

     $newitem             = $cartdata
     $newitem['randid']   = @strtoupper($this->random_key(12));
     $newitem['savetype'] = 'CART';
     $newitem['sortnum']  = $max;

     $cart[$max] = $newitem;

} // End of if statement.

Nick Hendler

Offline

 

#3 11-25-2024 10:17:19

polarize
Member
Registered: 11-15-2004
Posts: 309

Re: Favorite Items List

Thank you for getting back to me Nick.

I'm still trying to get used to understanding and working with code.  Is this the correct format?

Code:

// +------------------------------------------------------------------+
// | Function: movecart                                               |
// +------------------------------------------------------------------+

function movecart () {

// +--
// | This function moves an item from a user's shopping cart to their
// | wish list and visa-versa.
// +--

$cart     = $this->globals('ecom.cart_contents');
$ref      = $this->globals('core.ref');
$savetype = 'CART';

foreach ($cart as $num => $cartdata) {

     if ($cartdata['offergroup'] != $ref) {continue;}

     $savetype = $cartdata['savetype'];

     if ($savetype == 'CART') {

     $cart[$num]['savetype'] = 'WISHLIST';

} else {

     $max = $this->globals('ecom.cart_max'); $max++; $this->globals('ecom.cart_max',$max);

     $newitem             = $cartdata
     $newitem['randid']   = @strtoupper($this->random_key(12));
     $newitem['savetype'] = 'CART';
     $newitem['sortnum']  = $max;

     $cart[$max] = $newitem;

} // End of if statement.

} // End of foreach statement.

// +--
// | Save the cart.
// +--

$this->savecart($cart);

// +--
// | Print a message and redirect back to the cart.
// +--

$this->print_message('ecom','cartcnfmove');

if ($this->debug) {$this->debugger("movecart: Moved item '{$ref}' in user cart.");}

// +--
// | Check the cart now.
// +--

$this->check_cart();

// +--
// | Return the cart or wish list.
// +--

if   ($savetype == 'WISHLIST') {return $this->exec_namespace(array('app' => 'ecom', 'namespace' => 'viewwishlist', 'type' => '*', 'params' => null));}
else                           {return $this->exec_namespace(array('app' => 'ecom', 'namespace' => 'viewcart', 'type' => '*', 'params' => null));}

} // End of function.

Also, does this part of the code belong or is something wrong with leaving both of these End of Statement lines in there?

Code:

} // End of if statement.

} // End of foreach statement.

Finally, Do we need to copy this entire file and path into the custom directory for keeping everything clean?

Thank you


Using Kryptronic K9! smile
Previous Versions:
ClickCartPro 8
ClickCartPro 7
ClickCartPro 6
ClickCartPro 5.1

Offline

 

#4 11-26-2024 08:15:17

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19850
Website

Re: Favorite Items List

That's good.  Your indentation is off so it looks weird, but the code is right.  Correct - save a modded copy of that file to {private}/custom/apps/ecom/ECOM_Cart/ECOM_Cart.php.  Your file will run instead of the system file.


Nick Hendler

Offline

 

Board footer