Source of file CanAddToWishList.php
Size: 1,864 Bytes - Last Modified: 2021-12-23T10:03:31+00:00
/var/www/docs.ssmods.com/process/src/code/CanAddToWishList.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 | <?php /** * DataExtension for buyable objects to all them to be * on a wishlist. * * @author Mark Guinn <mark@adaircreative.com> * @date 08.07.2013 * @package ecommerce_wishlist */ class CanAddToWishList extends DataExtension { /** * @return string */ public function WishListAddLink() { return WishListPage::add_item_link($this->getOwner()->ID, $this->getOwner()->ClassName); } /** * @return string */ public function WishListRemoveLink() { return WishListPage::remove_item_link($this->getOwner()->ID, $this->getOwner()->ClassName); } /** * @return bool */ public function IsInWishList() { $item = $this->WishListItem(); return $item && $item->exists(); } /** * IF this item is an any of the current member's wishlists, * returns the wishlist item record. * * NOTE: in order to be consistent with Product::OrderItem * this method returns a record NO MATTER WHAT, so you'll * have to check $rec->exists() to see if it's in the cart. * * @return WishListItem */ public function WishListItem() { return $this->getOwner()->WishListItems()->first(); } /** * IF this item is an any of the current member's wishlists, * returns the wishlist item records. * * @return DataList */ public function WishListItems() { $listWhere = sprintf( '"WishList"."ID" = "WishListItem"."WishListID" AND "WishList"."OwnerID" = \'%d\'', Member::currentUserID()); return WishListItem::get() ->innerJoin('WishList', $listWhere) ->filter(array( 'BuyableID' => $this->getOwner()->ID, 'BuyableClassName' => $this->getOwner()->ClassName, )); } } |