View Single Post
  #1  
Old 03-02-2018, 08:34 AM
 
Soptareanu Alex Soptareanu Alex is offline
 

Member
  
Join Date: Sep 2016
Posts: 24
 

Default Date Picker in Customer Zone

Hello. I need to include datepicker plugin into my customer zone, in order to show a calendar intro checkout page.
This is my View Class :
<?php
// vim: set ts=4 sw=4 sts=4 et:

/**
* Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
* See https://www.x-cart.com/license-agreement.html for license details.
*/

namespace XLite\Module\XGhosty\Disponibility\View\Checkout;

use \XLite\Core\Database as _Db;

/**
* Cart items
*
* @ListChild (list="checkout.shipping.selected.sub.payment", weight="1000", zone="customer")
*/

class Calendar extends \XLite\View\AView
{
/**
* Return widget default template
*
* @return string
*/
protected function getDefaultTemplate()
{
return 'modules/XGhosty/Disponibility/checkout/calendar.twig';
}

/**
* Register CSS files
*
* @return array
*/
public function getCSSFiles()
{
$list = parent::getCSSFiles();
$list[] = 'modules/XGhosty/Disponibility/assets/css/jquery.datepick.css';

return $list;
}

/**
* Get JS files
*
* @return array
*/
public function getJSFiles()
{
$list = parent::getJSFiles();
$list[] = 'modules/XGhosty/Disponibility/assets/js/jquery.plugin.min.js'; // Aici imi pun js-urile mele
$list[] = 'modules/XGhosty/Disponibility/assets/js/jquery.datepick.min.js'; // Aici imi pun js-urile mele

return $list;
}

/**
* Get cart items
*
* @return array
*/
public function getItems()
{
return $this->getCart()
? $this->getCart()->getItems()
: [];
}
}

The problem is that .js and .css resources didn't load in my layout.
This is my twig file :
{% if this.showDeliveryDate() is not null %}
<div>
<span> Delivery date is : <b> {{ this.showDeliveryDate() }} </b> </span>
</div>
{% endif %}
<script>

$(function(){
console.log("asd");
});

$(document).ready(function(){
$('#defaultPopup').datepick({minDate: new Date(2014, 12-1, 25)}); // This is how I want to init my plugin in page !!
});
__________________
alex
Reply With Quote