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.
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?
// +------------------------------------------------------------------+ // | 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.
Offline
Well the magic is here:
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:
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.
Offline
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?
// +------------------------------------------------------------------+ // | 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?
} // 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
Offline
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.
Offline