`;
}
// Add to cart handler
function pagelayer_render_pl_kkart_add_to_cart(el){
el['atts']['kkart_cart_form'] = ``;
}
function pagelayer_render_end_pl_kkart_add_to_cart(el){
kkart_pl_product_quantity(el.$);
}
//Product Gallery
function pagelayer_render_pl_kkart_img_gallery(el){
var default_img = [];
// Set default image for the editor
for(var i=1; i < 6; i++){
default_img['i1.'+i] = pagelayer.blank_img;
}
//The URLs
var img_urls = !pagelayer_empty(el.tmp['ids-urls']) ? JSON.parse(el.tmp['ids-urls']) : default_img;
var all_urls = !pagelayer_empty(el.tmp['ids-all-urls']) ? JSON.parse(el.tmp['ids-all-urls']) : [];
var img_title = !pagelayer_empty(el.tmp['ids-all-titles']) ? JSON.parse(el.tmp['ids-all-titles']) : [];
var img_links = !pagelayer_empty(el.tmp['ids-all-links']) ? JSON.parse(el.tmp['ids-all-links']) : [];
//console.log(all_urls);
var primary_image = '';
var gallery_html = '';
var i=0;
for (var x in img_urls){
var active_class = "";
//Use the default URL first
var url = img_urls[x];
if(i == 0){
primary_image = '';
}
//But if we have a custom size, use that
if(el.atts['size'] != 'custom' && x in all_urls && el.atts['size'] in all_urls[x]){
url = all_urls[x][el.atts['size']];
}
if(i == 0){
active_class = "kkart-product-active";
}
gallery_html += '
';
i++;
}
el.atts['primary_image'] = primary_image;
el.atts['gallery_html'] = gallery_html;
}
// Render the image slider
function pagelayer_render_end_pl_kkart_img_gallery(el){
if(pagelayer_empty(el.atts['pzoom'])){
el.$.unbind('mousemove mouseenter mouseleave');
}
kkart_pl_product_slider(el.$);
}
// Billing fields handler
function pagelayer_render_pl_kkart_billing_fields(el){
var fields_html = '';
var name = el.atts['field_name'];
if(el.atts['type'] == 'number'){
fields_html = '';
}else if(el.atts['type'] == 'email'){
fields_html = '';
}else if(el.atts['type'] == 'url'){
fields_html = '';
}else{
fields_html = '';
}
el.atts['fields_html'] = fields_html;
}
// Shipping fields handler
function pagelayer_render_pl_kkart_shipping_fields(el){
var fields_html = '';
var name = el.atts['field_name'];
if(el.atts['type'] == 'number'){
fields_html = '';
}else if(el.atts['type'] == 'email'){
fields_html = '';
}else if(el.atts['type'] == 'url'){
fields_html = '';
}else{
fields_html = '';
}
el.atts['fields_html'] = fields_html;
}
////////////////////////////////////////////
//// Copied from pagelayer
////////////////////////////////////////////
// Render the related product
function pagelayer_render_pl_kkart_product_related(el){
el.atts['related_products'] = '';
// if is related
if(el['atts']['select_product'] == 'related'){
var args = {
'posts_per_page' : 4,
'columns' : 4,
'orderby' : el.atts['orderby'],
'order' : el.atts['order'],
};
if ( ! pagelayer_empty( el['atts']['posts_per_page'] ) ) {
args['posts_per_page'] = el['atts']['posts_per_page'];
}
if ( ! pagelayer_empty( el['atts']['columns'] ) ) {
args['columns'] = el['atts']['columns'];
}
// Clear any previous timeout
clearTimeout(product_data_timer[el.id]);
// Set a timer for constant change
product_data_timer[el.id] = setTimeout(function(){
jQuery.ajax({
url: pagelayer_ajax_url+'&action=pagelayer_product_related&postID='+pagelayer_postID,
type: 'post',
data: {
pagelayer_nonce: pagelayer_ajax_nonce,
pagelayer_args: args,
},
success: function(response){
el.$.find('.pagelayer-product-related-container').html(response);
}
});
}, 200);
// If is upsell
}else if(el['atts']['select_product'] == 'upsell'){
var limit = '-1';
var columns = 4;
var orderby = el.atts['orderby'];
var order = el.atts['order'];
if ( ! pagelayer_empty( el.atts['columns'] ) ) {
columns = el.atts['columns'];
}
// Clear any previous timeout
clearTimeout(product_data_timer[el.id]);
// Set a timer for constant change
product_data_timer[el.id] = setTimeout(function(){
jQuery.ajax({
url: pagelayer_ajax_url+'&action=pagelayer_product_upsell&postID='+pagelayer_postID,
type: 'post',
data: {
pagelayer_nonce: pagelayer_ajax_nonce,
limit: limit,
columns: columns,
orderby: orderby,
order: order,
},
success: function(response){
el.$.find('.pagelayer-product-related-container').html(response);
}
});
}, 200);
}
}
// Render the kkart pages
function pagelayer_render_pl_kkart_pages(el){
el.atts['page_content'] = '';
var shortcode ='';
// if is not empty
if( !pagelayer_empty(el.atts['pages']) ){
shortcode = '['+ el.atts['pages'] +']';
}
jQuery.ajax({
url: pagelayer_ajax_url+'&action=pagelayer_do_shortcodes',
type: 'post',
data: {
pagelayer_nonce: pagelayer_ajax_nonce,
shortcode_data: shortcode,
},
success: function(response){
// If the content is empty
if(pagelayer_empty(response)){
response = '
Content not found
';
}
// if is checkout page
if ( 'kkart_checkout' === el.atts['pages'] && '' == $content ) {
response = '
Your cart is currently empty.
';
}
el.$.find('.pagelayer-woo-pages-container').html(response);
}
});
}
// Render the kkart pages
function pagelayer_render_pl_kkart_product_categories(el){
el.atts['product_categories'] = '';
// Clear any previous timeout
clearTimeout(product_data_timer[el.id]);
// Set a timer for constant change
product_data_timer[el.id] = setTimeout(function(){
jQuery.ajax({
url: pagelayer_ajax_url+'&action=pagelayer_product_categories',
type: 'post',
data: {
pagelayer_nonce: pagelayer_ajax_nonce,
atts: el.atts,
},
success: function(response){
el.$.find('.pagelayer-product-categories-container').html(response);
}
});
}, 200);
}
// Render the archive products
function pagelayer_render_pl_kkart_product_archives(el){
return;
el.atts['product_archives'] = '';
// Clear any previous timeout
clearTimeout(product_data_timer[el.id]);
// Set a timer for constant change
product_data_timer[el.id] = setTimeout(function(){
jQuery.ajax({
url: pagelayer_ajax_url+'&action=kkart_product_archives',
type: 'post',
data: {
pagelayer_nonce: pagelayer_ajax_nonce,
atts: el.atts,
},
success: function(response){
el.$.find('.pagelayer-product-archives-container').html(response);
}
});
}, 200);
}
// Render the products
function pagelayer_render_end_pl_kkart_products(el){
pagelayer_owl_destroy(el.$, '.pagelayer-products-container');
kkart_products_handler(el.$);
}
// Render the Demo Description handler
function pagelayer_render_pl_kkart_short_desc(el){
el.atts['product_short_desc'] = 'Demo Description';
}
// Render the products
function pagelayer_render_end_pl_kkart_menu_cart(el){
pagelayer_woo_menu_cart(el.$);
}
// Render the product thumbnail
function pagelayer_render_pl_kkart_archive_thumb(el){
var default_img = [];
var thumb = '';
// Set default image for the editor
if(el.atts['gallery']){
for(var i=0; i < 5; i++){
default_img[i] = [];
default_img[i]['url'] = pagelayer.blank_img;
}
}else{
default_img['url'] = pagelayer.blank_img;
}
var img_urls = !pagelayer_empty(el.tmp['ids-urls']) ? JSON.parse(el.tmp['ids-urls']) : default_img;
var all_urls = !pagelayer_empty(el.tmp['ids-all-urls']) ? JSON.parse(el.tmp['ids-all-urls']) : [];
if(el.atts['gallery']){
thumb = '
';
for(var i=0; i < 5; i++){
var url = '';
if(i in img_urls){
url = img_urls[i]['url'];
if(el.atts['size'] != 'custom' && i in all_urls && el.atts['size'] in all_urls[i]){
url = all_urls[i][el.atts['size']];
}
}else{
url = img_urls['url'];
if(el.atts['size'] != 'custom' && el.atts['size'] in all_urls){
url = all_urls[el.atts['size']];
}
}
thumb += '
';
}
thumb += '
';
}else{
var x = 0;
var url = '';
if(x in img_urls){
url = img_urls[x]['url'];
if(el.atts['size'] != 'custom' && x in all_urls && el.atts['size'] in all_urls[x]){
url = all_urls[x][el.atts['size']];
}
}else{
url = img_urls['url'];
if(el.atts['size'] != 'custom' && el.atts['size'] in all_urls){
url = all_urls[el.atts['size']];
}
}
thumb = '';
}
el['atts']['product_thumb'] = thumb;
if('controls' in el.atts && (el.atts['controls'] == 'arrows' || el.atts['controls'] == 'none')){
el.CSS.attr.push({'sel': '.kkart-thumbnail-gallery', 'val': 'data-pager="false"'});
}
if('controls' in el.atts && (el.atts['controls'] == 'pager' || el.atts['controls'] == 'none')){
el.CSS.attr.push({'sel': '.kkart-thumbnail-gallery', 'val': 'data-controls="false"'});
}
}
// Render the archive thumbnail
function pagelayer_render_end_pl_kkart_archive_thumb(el){
if(el.atts['gallery']){
pagelayer_owl_destroy(el.$, '.kkart-thumbnail-gallery');
kkart_thumbnail_img_slider(el.$);
}
}
// Render the product Title
function pagelayer_render_pl_kkart_title(el){
el.atts['product_title'] = 'Product Title';
}
// Render the product Rating
function pagelayer_render_pl_kkart_product_rating(el){
el.atts['product_rating'] = 2.5;
el.atts['product_review_count'] = 1;
}
function pagelayer_render_end_pl_kkart_product_rating(el){
var jEle = el.$.find('.pagelayer-stars-container');
pagelayer_stars(jEle);
}
function pagelayer_render_pl_kkart_sale(el){
el.atts['is_on_sale'] = true;
if(el.atts['show_discount']){
el.atts['sale_discount'] = '13%';
}
}
// Cart item count
function pagelayer_render_pl_kkart_cart_item_count(el){
el.atts['item_count'] = '1';
}
function pagelayer_render_pl_kkart_addi_info(el){
el.atts['product_addi_info_heading'] = 'Additional Information';
el.atts['product_addi_info'] = '