Skip to content

Commit

Permalink
Split templates into logical blocks to make extending easier for merc…
Browse files Browse the repository at this point in the history
…hants
  • Loading branch information
Christoffer Lindqvist committed Sep 25, 2015
1 parent 726486d commit 6eb76a1
Show file tree
Hide file tree
Showing 22 changed files with 742 additions and 173 deletions.
70 changes: 70 additions & 0 deletions Views/frontend/plugins/nosto_tagging/addtocart_script.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{**
* Copyright (c) 2015, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <shopware@nosto.com>
* @copyright Copyright (c) 2015 Nosto Solutions Ltd (http://www.nosto.com)
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*}

{block name="nosto_addtocart_script"}
<script type="text/javascript">
//<![CDATA[
{literal}
if (typeof Nosto === "undefined") {
var Nosto = {};
}
{/literal}
Nosto.addProductToCart = function (productNumber) {
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "{url controller=checkout action=addArticle}");
var hiddenFields = {
"sActionIdentifier": "{$sUniqueRand}",
"sAdd": productNumber,
"sQuantity": 1
};
for(var key in hiddenFields) {
if(hiddenFields.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", hiddenFields[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
};
//]]>
</script>
{/block}
50 changes: 50 additions & 0 deletions Views/frontend/plugins/nosto_tagging/cart_tagging.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{**
* Copyright (c) 2015, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <shopware@nosto.com>
* @copyright Copyright (c) 2015 Nosto Solutions Ltd (http://www.nosto.com)
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*}

{block name="nosto_cart"}
<div class="nosto_cart" style="display:none">
{if isset($nostoCart) && is_object($nostoCart)}
{foreach from=$nostoCart->getLineItems() item=lineItem}
<div class="line_item">
<span class="product_id">{$lineItem->getProductId()|escape:'htmlall':'UTF-8'}</span>
<span class="quantity">{$lineItem->getQuantity()|escape:'htmlall':'UTF-8'}</span>
<span class="name">{$lineItem->getName()|escape:'htmlall':'UTF-8'}</span>
<span class="unit_price">{$lineItem->getUnitPrice()->getPrice()|number_format:2:".":""}</span>
<span class="price_currency_code">{$lineItem->getCurrency()->getCode()|escape:'htmlall':'UTF-8'}</span>
</div>
{/foreach}
{/if}
</div>
{/block}
4 changes: 1 addition & 3 deletions Views/frontend/plugins/nosto_tagging/checkout/cart.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@
*}

{block name="frontend_index_content" append}
<div class="nosto_element" id="nosto-page-cart1"></div>
<div class="nosto_element" id="nosto-page-cart3"></div>
<div class="nosto_element" id="nosto-page-cart2"></div>
{include file="frontend/plugins/nosto_tagging/checkout/cart_recos.tpl"}
{/block}
40 changes: 40 additions & 0 deletions Views/frontend/plugins/nosto_tagging/checkout/cart_recos.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{**
* Copyright (c) 2015, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <shopware@nosto.com>
* @copyright Copyright (c) 2015 Nosto Solutions Ltd (http://www.nosto.com)
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*}

{block name="nosto_cart_recos"}
<div class="nosto_element" id="nosto-page-cart1"></div>
<div class="nosto_element" id="nosto-page-cart3"></div>
<div class="nosto_element" id="nosto-page-cart2"></div>
{/block}
27 changes: 2 additions & 25 deletions Views/frontend/plugins/nosto_tagging/checkout/finish.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,5 @@
*}

{block name="frontend_index_content" append}
{if isset($nostoOrder) && is_object($nostoOrder)}
<div class="nosto_purchase_order" style="display:none">
<span class="order_number">{$nostoOrder->getOrderNumber()|escape:'htmlall':'UTF-8'}</span>
<span class="order_status_code">{$nostoOrder->getOrderStatus()->getCode()|escape:'htmlall':'UTF-8'}</span>
<span class="order_status_label">{$nostoOrder->getOrderStatus()->getLabel()|escape:'htmlall':'UTF-8'}</span>
<span class="payment_provider">{$nostoOrder->getPaymentProvider()|escape:'htmlall':'UTF-8'}</span>
<div class="buyer">
<span class="first_name">{$nostoOrder->getBuyerInfo()->getFirstName()|escape:'htmlall':'UTF-8'}</span>
<span class="last_name">{$nostoOrder->getBuyerInfo()->getLastName()|escape:'htmlall':'UTF-8'}</span>
<span class="email">{$nostoOrder->getBuyerInfo()->getEmail()|escape:'htmlall':'UTF-8'}</span>
</div>
<div class="purchased_items">
{foreach from=$nostoOrder->getPurchasedItems() item=lineItem}
<div class="line_item">
<span class="product_id">{$lineItem->getProductId()|escape:'htmlall':'UTF-8'}</span>
<span class="quantity">{$lineItem->getQuantity()|escape:'htmlall':'UTF-8'}</span>
<span class="name">{$lineItem->getName()|escape:'htmlall':'UTF-8'}</span>
<span class="unit_price">{$lineItem->getUnitPrice()->getPrice()|number_format:2:".":""}</span>
<span class="price_currency_code">{$lineItem->getCurrency()->getCode()|escape:'htmlall':'UTF-8'}</span>
</div>
{/foreach}
</div>
</div>
{/if}
{/block}
{include file="frontend/plugins/nosto_tagging/checkout/order_tagging.tpl"}
{/block}
61 changes: 61 additions & 0 deletions Views/frontend/plugins/nosto_tagging/checkout/order_tagging.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{**
* Copyright (c) 2015, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <shopware@nosto.com>
* @copyright Copyright (c) 2015 Nosto Solutions Ltd (http://www.nosto.com)
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*}

{block name="nosto_order"}
{if isset($nostoOrder) && is_object($nostoOrder)}
<div class="nosto_purchase_order" style="display:none">
<span class="order_number">{$nostoOrder->getOrderNumber()|escape:'htmlall':'UTF-8'}</span>
<span class="order_status_code">{$nostoOrder->getOrderStatus()->getCode()|escape:'htmlall':'UTF-8'}</span>
<span class="order_status_label">{$nostoOrder->getOrderStatus()->getLabel()|escape:'htmlall':'UTF-8'}</span>
<span class="payment_provider">{$nostoOrder->getPaymentProvider()|escape:'htmlall':'UTF-8'}</span>
<div class="buyer">
<span class="first_name">{$nostoOrder->getBuyerInfo()->getFirstName()|escape:'htmlall':'UTF-8'}</span>
<span class="last_name">{$nostoOrder->getBuyerInfo()->getLastName()|escape:'htmlall':'UTF-8'}</span>
<span class="email">{$nostoOrder->getBuyerInfo()->getEmail()|escape:'htmlall':'UTF-8'}</span>
</div>
<div class="purchased_items">
{foreach from=$nostoOrder->getPurchasedItems() item=lineItem}
<div class="line_item">
<span class="product_id">{$lineItem->getProductId()|escape:'htmlall':'UTF-8'}</span>
<span class="quantity">{$lineItem->getQuantity()|escape:'htmlall':'UTF-8'}</span>
<span class="name">{$lineItem->getName()|escape:'htmlall':'UTF-8'}</span>
<span class="unit_price">{$lineItem->getUnitPrice()->getPrice()|number_format:2:".":""}</span>
<span class="price_currency_code">{$lineItem->getCurrency()->getCode()|escape:'htmlall':'UTF-8'}</span>
</div>
{/foreach}
</div>
</div>
{/if}
{/block}
44 changes: 44 additions & 0 deletions Views/frontend/plugins/nosto_tagging/customer_tagging.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{**
* Copyright (c) 2015, Nosto Solutions Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @author Nosto Solutions Ltd <shopware@nosto.com>
* @copyright Copyright (c) 2015 Nosto Solutions Ltd (http://www.nosto.com)
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
*}

{block name="nosto_customer"}
{if isset($nostoCustomer) && is_object($nostoCustomer)}
<div class="nosto_customer" style="display:none">
<span class="first_name">{$nostoCustomer->getFirstName()|escape:'htmlall':'UTF-8'}</span>
<span class="last_name">{$nostoCustomer->getLastName()|escape:'htmlall':'UTF-8'}</span>
<span class="email">{$nostoCustomer->getEmail()|escape:'htmlall':'UTF-8'}</span>
</div>
{/if}
{/block}
57 changes: 2 additions & 55 deletions Views/frontend/plugins/nosto_tagging/detail/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,59 +34,6 @@
*}

{block name="frontend_index_content" append}
<div class="nosto_element" id="nosto-page-product1"></div>
<div class="nosto_element" id="nosto-page-product2"></div>
<div class="nosto_element" id="nosto-page-product3"></div>
{if isset($nostoProduct) && is_object($nostoProduct)}
<div class="nosto_product" style="display: none">
<span class="url">{$nostoProduct->getUrl()|escape:'htmlall':'UTF-8'}</span>
<span class="product_id">{$nostoProduct->getProductId()|escape:'htmlall':'UTF-8'}</span>
<span class="name">{$nostoProduct->getName()|escape:'htmlall':'UTF-8'}</span>
<span class="image_url">{$nostoProduct->getImageUrl()|escape:'htmlall':'UTF-8'}</span>
{if $nostoProduct->getPrice()}
<span class="price">{$nostoProduct->getPrice()->getPrice()|number_format:2:".":""}</span>
{/if}
{if $nostoProduct->getCurrency()}
<span class="price_currency_code">{$nostoProduct->getCurrency()->getCode()|escape:'htmlall':'UTF-8'}</span>
{/if}
{if $nostoProduct->getAvailability()}
<span class="availability">{$nostoProduct->getAvailability()->getAvailability()|escape:'htmlall':'UTF-8'}</span>
{/if}
{foreach from=$nostoProduct->getCategories() item=category}
<span class="category">{$category|escape:'htmlall':'UTF-8'}</span>
{/foreach}
{if $nostoProduct->getFullDescription()}
<span class="description">{$nostoProduct->getFullDescription()|escape:'htmlall':'UTF-8'}</span>
{/if}
{if $nostoProduct->getListPrice()}
<span class="list_price">{$nostoProduct->getListPrice()->getPrice()|number_format:2:".":""}</span>
{/if}
{if $nostoProduct->getBrand()}
<span class="brand">{$nostoProduct->getBrand()|escape:'htmlall':'UTF-8'}</span>
{/if}
{foreach from=$nostoProduct->getTags() key=type item=tags}
{foreach from=$tags item=tag}
<span class="{$type|escape:'quotes'}">{$tag|escape:'htmlall':'UTF-8'}</span>
{/foreach}
{/foreach}
{if $nostoProduct->getDatePublished()}
<span class="date_published">{$nostoProduct->getDatePublished()|date_format:'%Y-%m-%d'}</span>
{/if}
{if $nostoProduct->getPriceVariationId()}
<span class="variation_id">{$nostoProduct->getPriceVariationId()|escape:'htmlall':'UTF-8'}</span>
{foreach from=$nostoProduct->getPriceVariations() item=variation}
<div class="variation">
<span class="variation_id">{$variation->getId()->getId()|escape:'htmlall':'UTF-8'}</span>
<span class="price_currency_code">{$variation->getCurrency()->getCode()|escape:'htmlall':'UTF-8'}</span>
<span class="price">{$variation->getPrice()->getPrice()|number_format:2:".":""}</span>
<span class="list_price">{$variation->getListPrice()->getPrice()|number_format:2:".":""}</span>
<span class="availability">{$variation->getAvailability()->getAvailability()|escape:'htmlall':'UTF-8'}</span>
</div>
{/foreach}
{/if}
</div>
{/if}
{if isset($nostoCategory) && is_object($nostoCategory)}
<div class="nosto_category" style="display:none">{$nostoCategory->getCategoryPath()|escape:'htmlall':'UTF-8'}</div>
{/if}
{include file="frontend/plugins/nosto_tagging/detail/product_recos.tpl"}
{include file="frontend/plugins/nosto_tagging/detail/product_tagging.tpl"}
{/block}
Loading

0 comments on commit 6eb76a1

Please sign in to comment.