# Javascript shopping cart layout customization

**URL:** <https://www.virtocommerce.org/t/javascript-shopping-cart-layout-customization/124>\
**Category:** dev\
**Created:** [December 20, 2019, 11:33am UTC](https://www.virtocommerce.org/t/javascript-shopping-cart-layout-customization/124 "2019-12-20T11:33:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yecli](https://yyz2.discourse-cdn.com/flex032/user_avatar/www.virtocommerce.org/yecli/32/87_2.png) [@yecli](https://www.virtocommerce.org/u/yecli)\
**Post date:** [December 20, 2019, 11:33am UTC](https://www.virtocommerce.org/t/javascript-shopping-cart-layout-customization/124/1 "2019-12-20T11:33:41Z")

</div>

VirtoCommerce has a [Javascript shopping cart module](https://github.com/VirtoCommerce/vc-module-javascript-shoppingcart) that allows adding a basic shopping cart and checkout functionality to the website easily.  
The integration sample could be found [here](https://github.com/VirtoCommerce/vc-samples/tree/master/JsShoppngCartIntergationSample).

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/b045560c7f05360b9d8e5cae10b883e1cfb6f629.jpeg)

## Customizing the Javascript shopping cart or checkout forms layout/appearance

### Using CSS styles

You can override styles on the side of integration site. To set another card icon in the cart widget, override `.icon-cart` background:

```auto
.icon.icon-cart {
    background-image: url('your_image_url');
}

```

### Сhanging HTML markup

In case you need to change the HTML structure, [replace the required Angularjs templates](https://docs.angularjs.org/api/ng/service/%24templateCache) in your site code.

- By adding the script with template directly to your site DOM, e.g. for new cart widget template:

```auto
<script type="text/ng-template" id="cart.tpl.html">
    <button class="cart-btn" ng-click="$ctrl.openCart()">
        <span class="icon icon-cart"></span>
        <span class="cart-count" style="display:block" ng-bind="$ctrl.cartItemsCount" ng-cloak></span>
    </button>
</script>

```

- Or by including the script that replaces the template in Angularjs template cache.  
Add script reference into the site under `ng-app` directive after shopping cart scripts:

```auto
    <script type="text/javascript" src="http://localhost/admin/scripts/vc-shopping-cart"></script>    
    <script type="text/javascript" src="~/Scripts/extension.js"></script>

```

Example script content:

```auto
var cartModule = angular.module('virtoCommerce.cartModule');

cartModule.run(function($templateCache) {
    $templateCache.put('cart.tpl.html',
        '<button class="cart-btn" ng-click="$ctrl.openCart()">' +
	        '<span class="icon icon-cart"></span>' +
	        '<span class="cart-count" style="display:block" ng-bind="$ctrl.cartItemsCount" ng-cloak></span>'+
        '</button>'
    );
});

```

If you need further modifications (like controller logic), probably you need to implement your own Javascript shopping cart module based on [the existing one](https://github.com/VirtoCommerce/vc-module-javascript-shoppingcart).
