1999 Posts in 530 Topics by 433 members
E-Commerce Modules
SilverStripe Forums » E-Commerce Modules » [SOLVED] cart on every page
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 496 Views |
-
[SOLVED] cart on every page

20 September 2011 at 11:18pm
Hi
Can somebody point me in the right direction to add a cart to every page. I've tried integrating the "Cart Widget", but can't seem to get it to work.
I've successfully done this on a much older SilverStripe website, but it seems that with every revision of SS and the eCommerce module so much changes!
Thanks
-
Re: [SOLVED] cart on every page

23 September 2011 at 7:45pm Last edited: 23 September 2011 7:46pm
Hi
I don't know the specifics of the cart but one option to explore would be to extend SiteConfig with a function that returns the cart. Then call the function from all of your pages, for example inside the "SideBar" template if you have one e.g. $SiteConfig.ShowCart.
There are some examples of extending SiteConfig over at SSBits.com here.
I would start by taking the code from the "Cart Widget" and putting it into a function inside a SiteConfig extension.
Liam
-
Re: [SOLVED] cart on every page

4 October 2011 at 4:37am Last edited: 4 October 2011 4:41am
Thanks, Liam.
I have now sorted it. I decided against using the Cart Widget, as it didn't give me the detail which I needed. Instead, I copied the code from OrderInformation_Editable.ss to where I needed it, making a couple of minor changes, most importantly adding <% control SideCart %>
<table>
<tbody>
<% control SideCart %>
<% if Items %>
<% control Items %>
<% if ShowInTable %>
<tr id="$TableID" class="$Classes">
<td<% if Link %><% else %> id="$TableTitleID"<% end_if %> class="product title" scope="row"><% if Link %>
$Quantity x <a id="$TableTitleID" href="$Link" title="<% sprintf(_t("READMORE","Click here to read more on "%s""),$TableTitle) %>">$TableTitle</a>
<% else %>
$Quantity x $TableTitle
<% end_if %></td>
<td<% if Link %><% else %> id="$TableTitleID"<% end_if %> class="product title" scope="row"> </td>
<td class="right total" id="$TableTotalID">$Total.Nice</td>
<td class="right remove"><strong> <a class="ajaxQuantityLink" href="$removeallLink" title="<% sprintf(_t("REMOVEALL","Remove all of "%s" from your cart"),$TableTitle) %>"> <img src="ecommerce/images/remove.gif" alt="x"/> </a> </strong></td>
</tr>
<% end_if %>
<% end_control %>
<tr class="gap summary">
<td scope="row"><% _t("SUBTOTAL","Sub-total") %></td>
<td scope="row"> </td>
<td class="right" id="$TableSubTotalID">$SubTotal.Nice</td>
<td> </td>
</tr>
<% if Modifiers %>
<% control Modifiers %>
<% if ShowInTable %>
<tr id="$TableID" class="$Classes">
<td<% if Link %><% else %> id="$TableTitleID"<% end_if %> scope="row"><% if Link %>
<a id="$TableTitleID" href="$Link" title="<% sprintf(_t("READMORE","Click here to read more on "%s""),$TableTitle) %>">$TableTitle</a>
<% else %>
$TableTitle
<% end_if %></td>
<td<% if Link %><% else %> id="$TableTitleID"<% end_if %> scope="row"> </td>
<td<% if Link %><% else %> id="$TableTitleID"<% end_if %> scope="row"><span class="right">
<% if IsChargable %>
$Amount.Nice
<% else %>
-$Amount.Nice
<% end_if %>
</span></td>
<td><span class="right remove">
<% if CanRemove %>
<strong> <a class="ajaxQuantityLink" href="$removeLink" title="<% sprintf(_t("REMOVE","Remove "%s" from your order"),$TableTitle) %>"> <img src="ecommerce/images/remove.gif" alt="x"/></a></strong>
<% end_if %>
</span></td>
</tr>
<% end_if %>
<% end_control %>
<% end_if %>
<tr class="gap Total">
<td scope="row"><% _t("TOTAL","Total") %></td>
<td scope="row"> </td>
<td scope="row"><span class="right">$Total.Nice</span></td>
<td> </td>
</tr>
<% else %>
<tr>
<td colspan="6" scope="row" class="center"><% _t("NOITEMS","There are <strong>no</strong> items in your cart.") %></td>
</tr>
<% end_if %>
<% end_control %>
</tbody>
</table>After that, I added the following to mysite/Page.php
public function SideCart() {
return ShoppingCart::current_order();
}
And that was it
| 496 Views | ||
|
Page:
1
|
Go to Top |


