Commit d2b81e5b authored by Mario's avatar Mario

missing files


(cherry picked from commit ba4750f9)
parent e3f24db6
<div class="widget">
<div class="catalog-item-details dm42cart">
{{if $item.item_photo_url}}
<img src="{{$item.item_photo_url}}" class="w-100 rounded pb-2">
{{/if}}
<div class="catalog-item-desc pb-2">
{{$item.item_desc}}
</div>
<div class="catalog-item-price pb-2">
<span class="font-weight-bold">{{$item.item_price_label}}:</span> {{$item.item_price}}
</div>
{{if $item.info}}
<div class="catalog-item-info pb-2">
<i class="fa fa-info-circle"></i> {{$item.info}}
</div>
{{/if}}
</div>
<div class="catalog-item-cart-button dm42cart">
{{if $item.order_qty}}
{{if $item.maxcount != 1}}
<form method="post" action="{{$posturl}}?returnurl={{$returnurl}}">
<input type="hidden" name="cart_posthook" value="update_item">
<div class="input-group form-group">
<input class="form-control form-control-sm" type="text" name="qty-{{$item.id}}" value="{{$item.order_qty}}" style="width: 4em;float:left;">
<div class="input-group-append">
<button class="btn btn-sm btn-primary" type="submit" name="Submit" value="{{$item.item_sku}}">Update Quantity</button>
<button class="btn btn-sm btn-outline-danger btn-outline" type="submit" name="delsku" value="{{$item.item_sku}}" title="Remove from cart"><i class="fa fa-remove"></i></button>
</div>
</div>
</form>
{{else}}
<form method="post" action="{{$posturl}}?returnurl={{$returnurl}}">
<input type="hidden" name="cart_posthook" value="update_item">
<input type="hidden" name="delsku" value="{{$item.item_sku}}">
<b>Item Already in your cart!</b>
<button class="btn btn-sm btn-outline-danger btn-outline" type="submit" name="remove" title="Remove from cart"><i class="fa fa-remove"></i></button>
</form>
{{/if}}
{{else}}
<form method="post" action="{{$posturl}}{{if $returnurl}}?returnurl={{$returnurl}}{{/if}}">
<input type="hidden" name="cart_posthook" value="add_item">
<div class="input-group form-group">
<input class="form-control form-control-sm" type="text" name="qty" value="1">
<div class="input-group-append">
<button class="btn btn-sm btn-primary" type="submit" name="add" value="{{$item.item_sku}}">Add to Cart</button>
</div>
</div>
</form>
{{/if}}
</div>
<div class="clearfix"></div>
</div>
<?php
namespace Zotlabs\Widget;
class Catalogitem {
function widget($args) {
require_once('addon/cart/cart.php');
if (! isset($args['sku']))
return '';
$nick = cart_getnick();
if (! $nick)
return '';
$sku = preg_replace('/[^a-zA-Z0-9\-\_]/','',$args['sku']);
$info = bbcode($args['info']);
$id = '';
$count = 0;
$catalog_items = [];
call_hooks('cart_get_catalog',$catalog_items);
$catalog_item = [];
if (isset($catalog_items[$sku]))
$catalog_item = $catalog_items[$sku];
if(! $catalog_item)
return '';
$orderhash = cart_getorderhash(false);
if ($orderhash) {
$order = cart_loadorder($orderhash);
foreach ($order['items'] as $oitem) {
if ($oitem['item_sku'] == $sku) {
if ($id == '')
$id = $oitem['id'];
$count=$count+$oitem['item_qty'];
}
}
}
$templateinfo = ['name'=>'widget_catalogitem.tpl','path'=>'addon/cart/'];
$template = get_markup_template($templateinfo['name'],$templateinfo['path']);
$item = [
'id'=> $id,
'order_qty' => $count,
'item_sku' => $catalog_item['item_sku'],
'item_desc' => $catalog_item['item_desc'],
'item_price' => $catalog_item['item_price'],
'item_photo_url' => $catalog_item['item_photo_url'],
'item_price_label' => t('Price'),
'info' => (($info) ? $info : '')
];
$arr = [
'$item'=>$item,
'$posturl'=>'/cart/'.$nick.'/checkout'
];
if ($args['returnhere']) {
$arr['$returnurl'] = urlencode($_SERVER['REQUEST_URI']);
}
return replace_macros($template, $arr);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment