-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add twig tags for basic cart operations directly in templates
- Loading branch information
1 parent
f9792ae
commit b088bad
Showing
4 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
class MultiAddVariable | ||
{ | ||
|
||
public function multiAddToCart($cart, $items){ | ||
|
||
$error = ""; | ||
|
||
//Must be an array of items, each being a purchasable ID and a qty | ||
if(!is_array($items)){ | ||
return "Must supply an array of items, each with a purchasableId and a qty (and optionally note, options)"; | ||
} | ||
else { | ||
craft()->multiAdd_cart->multiAddToCart($cart, $items, $error); | ||
} | ||
|
||
if($error){ | ||
return $error; | ||
} | ||
else { | ||
return "Items added to cart"; | ||
} | ||
|
||
} | ||
|
||
public function removeAllLineItems($cart){ | ||
|
||
craft()->commerce_cart->clearCart($cart); | ||
|
||
} | ||
|
||
public function removeLineItem($cart, $lineItemId){ | ||
|
||
craft()->commerce_cart->removeFromCart($cart, $lineItemId); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters