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
Hello Nick,
I'm getting this error when running the new script...
Script Execution Error
syntax error, unexpected '$newitem' (T_VARIABLE)
File: /chroot/custom/apps/ecom/ECOM_Cart/ECOM_Cart.php Line: 2155 Error Number: 256
I checked permissions 0755 and even tried changing them to match the original file but that didn't change anything. The file is currently set to default 0644 and I have it in the custom directory path but renamed to ECOM_Cart_draft.php to keep it from trying to execute until this is figured out.
Is there something in here hanging it up?
Thanks
Offline
I added a semicolon to the end of line 2154 so it appears to be working now as far as moving the items from the wish list to the cart without deleting from the wish list. In testing I did notice however that if I delete something for the cart it is also deleting from the wish list while we want the wish list to remain unchanged unless the customer chooses to add or remove from the wish list specifically. Is there a way in this file to separate the delete so that it doesn't affect the wish list when something is deleted from the cart?
I figured out how to rename the header inside of the Wish List to Favorite Items but not how to rename the button link in Shopping Cart from Wish List to Favorite Items
Where can we rename the "Add to Wish List" to "Add to Favorites" and inside of Wish List "Move" to "Add to Cart" and in Shopping Cart "Move" renamed to "Add to Favorite Items".
Thank you
Last edited by polarize (01-11-2025 18:39:13)
Offline
For deletion from the cart, basically you want to modify the deletecart() function and make a mod similar to what you did in movecart(). As far as the language changes you're looking to do, replicate these in your {private}/custom directory and mod them there:
{private}/apps/ecom/ECOM/includes/prodshow.php - For the buttons on the product offer pages
{private}/apps/ecom/ECOM/includes/prodlistitem.php - For items in lists with add buttons
{private}/apps/ecom/ECOM/includes/catfeaturegriddetail.php - For items in category grids with add buttons
{private}/apps/ecom/ECOM/includes/cartdisplay.php - For the cart/wishlist page
Also check Store / Component / Settings / Language Strings for applicable settings to change.
Lastly, update entries in the 'core_namespaces' table using Raw DB Admin where the 'name' is 'Shopping Cart' or 'Wish List'.
Offline