$shop_archive_page_layout,
'widgets' => $widgets
);
}
}
// Single Product Layout & Widgets
if( ! function_exists( 'alagu_single_product' ) ) {
function alagu_single_product( $id , $position ) {
$widgets = array();
$settings = get_post_meta( $id, '_custom_settings', true );
if( is_array( $settings ) ) {
$settings = array_filter( $settings );
} else {
$settings = array(
'page-layout' => 'admin-option',
'show-upsell' => 'admin-option',
'show-related' => 'admin-option'
);
}
$prodcut_page_layout = $settings['page-layout'];
if( $prodcut_page_layout == 'admin-option' ) {
$prodcut_page_layout = alagu_get_option( 'site-global-sidebar-layout' );
$standard_sidebar = true;
if( $standard_sidebar ) {
$widgets[] = ( $position == "left" ) ? 'standard-sidebar-left' : 'standard-sidebar-right';
}
} elseif( $prodcut_page_layout == 'with-left-sidebar' || $prodcut_page_layout == 'with-right-sidebar' ) {
if( isset( $settings['show-standard-sidebar'] ) && $settings['show-standard-sidebar'] ) {
$widgets[] = ( $position == "left" ) ? 'standard-sidebar-left' : 'standard-sidebar-right';
}
$custom_widgets = isset( $settings['product-widgetareas'] ) ? $settings['product-widgetareas'] : array();
$custom_widgets = isset( $custom_widgets ) ? $custom_widgets : array ();
if( is_array( $custom_widgets ) ) {
$widgets = array_merge( $widgets, $custom_widgets );
}
}
return array(
'page-layout' => $prodcut_page_layout,
'widgets' => $widgets
);
}
}
// Single Product Settings
if( ! function_exists( 'alagu_single_product_settings' ) ) {
function alagu_single_product_settings ( $id ) {
$settings = get_post_meta( $id, '_custom_settings', true );
if( is_array( $settings ) ) {
$settings = array_filter( $settings );
} else {
$settings = array(
'page-layout' => 'admin-option',
'show-upsell' => 'admin-option',
'upsell-column' => 'admin-option',
'upsell-limit' => 'admin-option',
'show-related' => 'admin-option',
'related-column' => 'admin-option',
'related-limit' => 'admin-option'
);
}
if( isset( $settings['show-upsell'] ) && $settings['show-upsell'] == 'admin-option' ) {
$settings['show-upsell'] = alagu_get_option( 'dt-single-product-default-show-upsell' );
$settings['upsell-column'] = alagu_get_option( 'dt-single-product-upsell-column' );
$settings['upsell-limit'] = alagu_get_option( 'dt-single-product-upsell-limit' );
}
if( $settings['upsell-column'] == 'admin-option' ) {
$settings['upsell-column'] = alagu_get_option( 'dt-single-product-upsell-column' );
}
if( $settings['upsell-limit'] == 'admin-option' ) {
$settings['upsell-limit'] = alagu_get_option( 'dt-single-product-upsell-limit' );
}
if( isset( $settings['show-related'] ) && $settings['show-related'] == 'admin-option' ) {
$settings['show-related'] = alagu_get_option( 'dt-single-product-default-show-related' );
$settings['related-column'] = alagu_get_option( 'dt-single-product-related-column' );
$settings['related-limit'] = alagu_get_option( 'dt-single-product-related-limit' );
}
if( $settings['related-column'] == 'admin-option' ) {
$settings['related-column'] = alagu_get_option( 'dt-single-product-related-column' );
}
if( $settings['related-limit'] == 'admin-option' ) {
$settings['related-limit'] = alagu_get_option( 'dt-single-product-related-limit' );
}
return $settings;
}
}
// Remove Anonymous action
if( ! function_exists( 'alagu_woo_remove_anonymous_object_action' ) ) {
function alagu_woo_remove_anonymous_object_action( $tag, $class, $method, $priority = null ){
if( empty($GLOBALS['wp_filter'][ $tag ]) ){
return;
}
foreach ( $GLOBALS['wp_filter'][ $tag ] as $filterPriority => $filter ){
if( !($priority===null || $priority==$filterPriority) )
continue;
foreach ( $filter as $identifier => $function ){
if( is_array( $function)
and is_a( $function['function'][0], $class )
and $method === $function['function'][1]
){
remove_action(
$tag,
array ( $function['function'][0], $method ),
$filterPriority
);
}
}
}
}
}
// Product Loop Column Class
if( ! function_exists( 'alagu_woo_loop_column_class' ) ) {
function alagu_woo_loop_column_class($columns) {
$columns = intval( $columns );
$options = alagu_shop_archive_page();
if($options['page-layout'] == 'with-left-sidebar' || $options['page-layout'] == 'with-right-sidebar') {
switch( $columns ) {
case 1:
$class = 'dt-col dt-col-xs-12 dt-col-sm-12 dt-col-md-12 dt-col-lg-12';
break;
case 2:
$class = 'dt-col dt-col-xs-12 dt-col-sm-12 dt-col-md-6 dt-col-qxlg-6 dt-col-qxlg-6 dt-col-lg-6';
break;
case 3:
$class = 'dt-col dt-col-xs-12 dt-col-sm-12 dt-col-md-6 dt-col-qxlg-4 dt-col-hxlg-4 dt-col-lg-4';
break;
case 4:
default:
$class = 'dt-col dt-col-xs-12 dt-col-sm-12 dt-col-md-6 dt-col-qxlg-4 dt-col-hxlg-4 dt-col-lg-4';
break;
}
} else {
switch( $columns ) {
case 1:
$class = 'dt-col dt-col-xs-12 dt-col-sm-12 dt-col-md-12 dt-col-lg-12';
break;
case 2:
$class = 'dt-col dt-col-xs-12 dt-col-sm-6 dt-col-md-6 dt-col-qxlg-6 dt-col-hxlg-6 dt-col-lg-6';
break;
case 3:
$class = 'dt-col dt-col-xs-12 dt-col-sm-6 dt-col-md-6 dt-col-qxlg-4 dt-col-hxlg-4 dt-col-lg-4';
break;
case 4:
default:
$class = 'dt-col dt-col-xs-12 dt-col-sm-6 dt-col-md-6 dt-col-qxlg-4 dt-col-hxlg-3 dt-col-lg-3';
break;
}
}
return $class;
}
}
// Check item is in cart
if(!function_exists('alagu_check_item_is_in_cart')) {
function alagu_check_item_is_in_cart( $product_id ){
if ( $product_id > 0 ) {
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$cart_product = $values['data'];
if( $product_id == $cart_product->get_id() ) {
return true;
}
}
}
return false;
}
}
// Single page product navigation
if( ! function_exists( 'alagu_single_product_nav' ) ) {
function alagu_single_product_nav() {
$next = get_next_post();
$prev = get_previous_post();
$next_id = ( ! empty( $next ) ) ? $next->ID : '';
$prev_id = ( ! empty( $prev ) ) ? $prev->ID : '';
$next = ( ! empty( $next ) ) ? wc_get_product( $next->ID ) : false;
$prev = ( ! empty( $prev ) ) ? wc_get_product( $prev->ID ) : false;
if ( ! empty( $next ) ) {
$next_thumbnail_id = get_post_thumbnail_id($next_id);
$next_image_src = wp_get_attachment_image_src($next_thumbnail_id, 'woocommerce_thumbnail', false);
$next_image_src = isset($next_image_src[0]) ? $next_image_src[0] : wc_placeholder_img_src( 'woocommerce_thumbnail' );
}
if ( ! empty( $prev ) ) {
$prev_thumbnail_id = get_post_thumbnail_id($prev_id);
$prev_image_src = wp_get_attachment_image_src($prev_thumbnail_id, 'woocommerce_thumbnail', false);
$prev_image_src = isset($prev_image_src[0]) ? $prev_image_src[0] : wc_placeholder_img_src( 'woocommerce_thumbnail' );
}
$output = '';
$output .= '
';
if ( ! empty( $prev ) ) {
$output .= '
';
}
$shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
$output .= '
'.esc_html__('Back to products', 'alagu').'';
if ( ! empty( $next ) ) {
$output .= '
';
}
$output .= '
';
return $output;
}
}
// Single page product sociable share / follow
if( ! function_exists( 'alagu_single_product_sociable_share_follow' ) ) {
function alagu_single_product_sociable_share_follow($product_id, $share_follow_type, $social_icon_style_cls, $social_icon_radius_cls, $social_icon_inline_alignment_cls) {
$sstitle = get_the_title($product_id);
$ssurl = get_permalink($product_id);
$output = '';
if($share_follow_type == 'share') {
$output .= '';
$output .= '
'.esc_html__('Share', 'alagu').'';
$output .= '
';
$show_sharer_facebook = alagu_get_option( 'dt-single-product-show-sharer-facebook' );
$show_sharer_delicious = alagu_get_option( 'dt-single-product-show-sharer-delicious' );
$show_sharer_digg = alagu_get_option( 'dt-single-product-show-sharer-digg' );
$show_sharer_stumbleupon = alagu_get_option( 'dt-single-product-show-sharer-stumbleupon' );
$show_sharer_twitter = alagu_get_option( 'dt-single-product-show-sharer-twitter' );
$show_sharer_googleplus = alagu_get_option( 'dt-single-product-show-sharer-googleplus' );
$show_sharer_linkedin = alagu_get_option( 'dt-single-product-show-sharer-linkedin' );
$show_sharer_pinterest = alagu_get_option( 'dt-single-product-show-sharer-pinterest' );
if($show_sharer_facebook == 'true') {
$output .= '-
';
}
if($show_sharer_delicious == 'true') {
$output .= '-
';
}
if($show_sharer_digg == 'true') {
$output .= '-
';
}
if($show_sharer_stumbleupon == 'true') {
$output .= '-
';
}
if($show_sharer_twitter == 'true') {
$output .= '-
';
}
if($show_sharer_googleplus == 'true') {
$output .= '-
';
}
if($show_sharer_linkedin == 'true') {
$output .= '-
';
}
if($show_sharer_pinterest == 'true') {
$featured_image_id = get_post_thumbnail_id($product_id);
$image_details = wp_get_attachment_image_src($featured_image_id, 'full');
$media = $image_details[0];
$output .= '-
';
}
$output .= '
';
$output .= '
';
} else if($share_follow_type == 'follow') {
$social_follow = array (
'delicious' => esc_html__('Delicious', 'alagu'),
'deviantart' => esc_html__('Deviantart', 'alagu'),
'digg' => esc_html__('Digg', 'alagu'),
'dribbble' => esc_html__('Dribbble', 'alagu'),
'envelope' => esc_html__('Envelope', 'alagu'),
'facebook' => esc_html__('Facebook', 'alagu'),
'flickr' => esc_html__('Flickr', 'alagu'),
'google-plus' => esc_html__('Google Plus', 'alagu'),
'gtalk' => esc_html__('GTalk', 'alagu'),
'instagram' => esc_html__('Instagram', 'alagu'),
'lastfm' => esc_html__('Lastfm', 'alagu'),
'linkedin' => esc_html__('Linkedin', 'alagu'),
'myspace' => esc_html__('Myspace', 'alagu'),
'picasa' => esc_html__('Picasa', 'alagu'),
'pinterest' => esc_html__('Pinterest', 'alagu'),
'reddit' => esc_html__('Reddit', 'alagu'),
'rss' => esc_html__('RSS', 'alagu'),
'skype' => esc_html__('Skype', 'alagu'),
'stumbleupon' => esc_html__('Stumbleupon', 'alagu'),
'technorati' => esc_html__('Technorati', 'alagu'),
'tumblr' => esc_html__('Tumblr', 'alagu'),
'twitter' => esc_html__('Twitter', 'alagu'),
'viadeo' => esc_html__('Viadeo', 'alagu'),
'vimeo' => esc_html__('Vimeo', 'alagu'),
'yahoo' => esc_html__('Yahoo', 'alagu'),
'youtube' => esc_html__('Youtube', 'alagu')
);
$socials_selected = array ();
foreach($social_follow as $socialfollow_key => $socialfollow) {
$show_follow_option = alagu_get_option( 'dt-single-product-show-follow-'.$socialfollow_key );
if($show_follow_option == 'true') {
array_push($socials_selected, $socialfollow_key);
}
}
$sociable_flds = alagu_get_sociable_links();
if( is_array( $sociable_flds ) && !empty( $sociable_flds ) ) {
$list = '';
foreach( $sociable_flds as $key => $sf) {
if(in_array($key, $socials_selected)) {
$list .= '';
}
}
if(!empty( $list )) {
$output .= '';
}
}
}
return $output;
}
}
// Product Shortcode - Ajax Call
if ( ! function_exists( 'alagu_products_ajax_call' ) ) {
function alagu_products_ajax_call() {
WPBMap::addAllMappedShortcodes();
$shortcodeattrs_array = json_decode(html_entity_decode(stripslashes($_REQUEST['shortcodeattrs'])), true);
$shortcode = '[dt_sc_products';
foreach($shortcodeattrs_array as $cda_key => $cda_val) {
$shortcode .= ' '.$cda_key.'="'.$cda_val.'"';
}
$current_page = isset($_REQUEST['current_page']) ? $_REQUEST['current_page'] : 1;
$offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
$shortcode .= ' current_page="'.$current_page.'"';
$shortcode .= ' offset="'.$offset.'"';
$shortcode .= ' /]';
echo do_shortcode($shortcode);
wp_die();
}
add_action( 'wp_ajax_alagu_products_ajax_call', 'alagu_products_ajax_call' );
add_action( 'wp_ajax_nopriv_alagu_products_ajax_call', 'alagu_products_ajax_call' );
}
// Product Shortcode - Ajax Pagination
if ( ! function_exists( 'alagu_products_ajax_pagination' ) ) {
function alagu_products_ajax_pagination($max_num_pages, $current_page, $post_per_page, $function_call, $output_div, $shortcode_attrs) {
$output = '';
if($max_num_pages > 1) {
$output .= '';
}
return $output;
}
}
// Product Countdown Timer
if ( ! function_exists( 'alagu_products_sale_countdown_timer' ) ) {
function alagu_products_sale_countdown_timer() {
$product_template = alagu_woo_product_single_template_option();
if( $product_template == 'woo-default' ) {
$sale_countdown_timer = alagu_get_option( 'dt-single-product-sale-countdown-timer' );
$sale_countdown_timer = (isset($sale_countdown_timer) && $sale_countdown_timer == 'true') ? true : false;
if(!$sale_countdown_timer) {
return;
}
}
$output = '';
global $product;
$sale_date_end = get_post_meta( $product->get_id(), '_sale_price_dates_to', true );
$sale_date_start = get_post_meta( $product->get_id(), '_sale_price_dates_from', true );
if ( $product->get_type() == 'variable' && $variations = $product->get_available_variations() ) {
$sale_date_end = get_post_meta( $variations[0]['variation_id'], '_sale_price_dates_to', true );
$sale_date_start = get_post_meta( $variations[0]['variation_id'], '_sale_price_dates_from', true );
}
$curent_date = strtotime( date( 'Y-m-d H:i:s' ) );
if ( $sale_date_end < $curent_date || $curent_date < $sale_date_start ) {
return;
}
$gmt_offset = get_option('gmt_offset');
echo '';
echo '
';
echo '
';
echo '
';
echo '
'.esc_html__('Day(s)', 'alagu').'
';
echo '
';
echo '
';
echo '
';
echo '
'.esc_html__('Hr(s)', 'alagu').'
';
echo '
';
echo '
';
echo '
';
echo '
'.esc_html__('Min(s)', 'alagu').'
';
echo '
';
echo '
';
echo '
';
echo '
'.esc_html__('Sec(s)', 'alagu').'
';
echo '
';
echo '
';
echo '
';
}
add_action( 'woocommerce_single_product_summary', 'alagu_products_sale_countdown_timer', 15 );
}
// Product Shortcode - Ajax Call
if ( ! function_exists( 'alagu_size_guide_popup' ) ) {
function alagu_size_guide_popup() {
$product_id = (isset($_REQUEST['product_id']) && $_REQUEST['product_id'] != '') ? $_REQUEST['product_id'] : -1;
if($product_id > -1) {
$settings = get_post_meta( $product_id, '_custom_settings', true );
$single_product_size_guides = (isset($settings['dt-single-product-size-guides']) && $settings['dt-single-product-size-guides'] != '') ? $settings['dt-single-product-size-guides'] : false;
if($single_product_size_guides) {
echo '';
}
}
wp_die();
}
add_action( 'wp_ajax_alagu_size_guide_popup', 'alagu_size_guide_popup' );
add_action( 'wp_ajax_nopriv_alagu_size_guide_popup', 'alagu_size_guide_popup' );
}
?>