Commit 9af1ae20 authored by Mario's avatar Mario

Merge branch 'cherry-pick-1cd0cb59' into 'dev'

cleanup and css fixes

See merge request !335
parents 34191c8c b886ed11
<div class="cart-button-wrapper dm42cart button" style="border-width:0px;">
<div class="cart-button dm42cart button">
{{if $item.order_qty}}
{{if $item.maxcount != 1}}
<form method="post" style="border-width:0px;" action="{{$posturl}}?returnurl={{$returnurl}}">
<div class="widget cart-button-wrapper dm42cart">
<div class="cart-button dm42cart">
{{if $item.order_qty}}
{{if $item.maxcount != 1}}
<form method="post" style="border-width:0px;" action="{{$posturl}}?returnurl={{$returnurl}}">
<input type="hidden" name="cart_posthook" value="update_item">
<input class="form-control form-control-sm" type="text" name="qty-{{$item.id}}" value="{{$item.order_qty}}" style="width: 4em;float:left;">
<button class="btn btn-primary" type="submit" name="Submit" value="{{$item.item_sku}}">Update Quantity</button>
<button class="btn btn-outline-danger btn-outline border-0" type="submit" name="delsku" value="{{$item.item_sku}}" title="Remove from cart"><i class="fa fa-remove"></i></button>
<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 border-0" 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" style="border-width:0px;" action="{{$posturl}}?returnurl={{$returnurl}}">
{{else}}
<form method="post" style="border-width:0px;" 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-outline-danger btn-outline border-0" type="submit" name="remove" title="Remove from cart"><i class="fa fa-remove"></i></button>
<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" style="border-width:0px;" 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}}
{{else}}
<form method="post" style="border-width:0px;" action="{{$posturl}}{{if $returnurl}}?returnurl={{$returnurl}}{{/if}}">
<input type="hidden" name="cart_posthook" value="add_item">
<input class="form-control form-control-sm" type="text" name="qty" value="1" style="width: 4em;float:left;">
<button class="btn btn-primary" type="submit" name="add" value="{{$item.item_sku}}">Add to Cart</button>
</form>
{{/if}}
</div>
<div style="clear:both;"></div>
</div>
<div class="clearfix"></div>
</div>
......@@ -5,38 +5,40 @@ namespace Zotlabs\Widget;
class Cartbutton {
//function widget_cartbutton ($args) {
function widget ($args) {
require_once("addon/cart/cart.php");
$owner_uid = \App::$profile_uid;
$nick = cart_getnick();
if (!$nick) { return ''; }
function widget ($args) {
require_once('addon/cart/cart.php');
$owner_uid = \App::$profile_uid;
$nick = cart_getnick();
if (!$nick) { return ''; }
$orderhash = cart_getorderhash(false);
if (!isset($args['sku'])) {
return '';
}
$sku = preg_replace('/[^a-zA-Z0-9\-\_]/','',$args['sku']);
$count=0;
if ($orderhash) {
$order = cart_loadorder($orderhash);
$id='';
foreach($order['items'] as $oitem) {
if($oitem['item_sku'] == $sku) {
if ($id == '') { $id = $oitem['id']; }
$count=$count+$oitem['item_qty'];
}
}
}
$templateinfo = array('name'=>'basic_widgetbutton.tpl','path'=>'addon/cart/');
call_hooks('cart_filter_widgetbutton_tpl',$templateinfo);
$template = get_markup_template($templateinfo['name'],$templateinfo['path']);
$item = Array('order_qty'=>$count, 'item_sku'=>$sku, 'id'=>$id);
$arr = Array('$item'=>$item,'$posturl'=>'/cart/'.$nick.'/checkout');
if ($args['returnhere']) {
$arr['$returnurl'] = urlencode($_SERVER['REQUEST_URI']);
}
return replace_macros($template, $arr );
}
$orderhash = cart_getorderhash(false);
if (!isset($args["sku"])) {
return '';
}
$sku = preg_replace('/[^a-zA-Z0-9\-\_]/','',$args["sku"]);
$count=0;
if ($orderhash) {
$order = cart_loadorder($orderhash);
$id='';
foreach($order['items'] as $oitem) {
if($oitem["item_sku"] == $sku) {
if ($id == '') { $id = $oitem["id"]; }
$count=$count+$oitem['item_qty'];
}
}
}
$templateinfo = array('name'=>'basic_widgetbutton.tpl','path'=>'addon/cart/');
call_hooks('cart_filter_widgetbutton_tpl',$templateinfo);
$template = get_markup_template($templateinfo['name'],$templateinfo['path']);
$item=Array('order_qty'=>$count, 'item_sku'=>$sku, 'id'=>$id);
$arr = Array('$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