Example #1
0
global $product, $woocommerce;
//if ( ! $product->is_purchasable() ) return;

if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'yith-woocompare-view-table' || defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    include $woocommerce->plugin_path() . '/templates/loop/add-to-cart.php';
    return;
}

//$woocommerce->integrations->integrations['sharethis']->sharethis_code = ''; // remove the code of share this and leave the js scripts

$count_buttons = 4; // number of buttons to show
$details = sprintf( '<a href="%s" rel="nofollow" title="%s" class="details">%s</a>', get_permalink(), apply_filters( 'yit_details_button', __( 'Details', 'yit' ) ), apply_filters( 'yit_details_button', __( 'Details', 'yit' ) ) );
$wishlist = do_shortcode( '[yith_wcwl_add_to_wishlist use_button_style="no"]' );
$compare = ( shortcode_exists( 'yith_compare_button' ) && ( get_option( 'yith_woocompare_compare_button_in_products_list' ) == 'yes' ) ) ? do_shortcode( '[yith_compare_button type="link"]' ) : '';
$is_wishlist = function_exists( 'yith_wcwl_is_wishlist' ) && yith_wcwl_is_wishlist();

$show_share = yit_get_option( 'shop-view-show-share' );
$sharethis_allowed = false;

$share = '';
if ( $show_share ) {
    if ( isset( $woocommerce->integrations->integrations['sharethis'] ) && $woocommerce->integrations->integrations['sharethis']->publisher_id ) {
        $sharethis_allowed = true;
        $share             = sprintf( '<a href="%s" rel="nofollow" title="%s" class="share" id="%s" onclick="return false;">%s</a>', '#', __( 'Share', 'yit' ), "share_$product->id", __( 'Share', 'yit' ) );
    }
    else {
        $share = sprintf( '<a href="#" class="yit_share share">' . __( 'Share', 'yit' ) . '</a>' );
    }
}
 /**
  * Redirect to cart after "Add to cart" button pressed on wishlist table
  *
  * @param $url string Original redirect url
  * @return string Redirect url
  * @since 2.0.0
  */
 public function redirect_to_cart($url, $product)
 {
     global $yith_wcwl_wishlist_token;
     $wishlist = $this->get_wishlist_detail_by_token($yith_wcwl_wishlist_token);
     $wishlist_id = $wishlist['ID'];
     if ($product->is_type('simple') && get_option('yith_wcwl_redirect_cart') == 'yes') {
         if (!(defined('DOING_AJAX') && DOING_AJAX) && yith_wcwl_is_wishlist()) {
             $url = add_query_arg('add-to-cart', $product->id, WC()->cart->get_cart_url());
         }
     }
     if (get_option('yith_wcwl_remove_after_add_to_cart') == 'yes') {
         if (!(defined('DOING_AJAX') && DOING_AJAX) && yith_wcwl_is_wishlist()) {
             $url = add_query_arg(array('remove_from_wishlist_after_add_to_cart' => $product->id, 'wishlist_id' => $wishlist_id, 'wishlist_token' => $yith_wcwl_wishlist_token), $url);
         }
     }
     return apply_filters('yit_wcwl_add_to_cart_redirect_url', esc_url($url));
 }
 /**
  * Redirect to cart after "Add to cart" button pressed on wishlist table
  *
  * @param $url string Original redirect url
  * @return string Redirect url
  * @since 2.0.0
  */
 public function redirect_to_cart($url, $product)
 {
     if ($product->is_type('simple') && get_option('yith_wcwl_redirect_cart') == 'yes') {
         if (!(defined('DOING_AJAX') && DOING_AJAX) && yith_wcwl_is_wishlist()) {
             $url = add_query_arg('add-to-cart', $product->id, WC()->cart->get_cart_url());
         }
     }
     if (get_option('yith_wcwl_remove_after_add_to_cart') == 'yes') {
         if (!(defined('DOING_AJAX') && DOING_AJAX) && yith_wcwl_is_wishlist()) {
             $url = add_query_arg('remove_from_wishlist_after_add_to_cart', $product->id, $url);
         }
     }
     return apply_filters('yit_wcwl_add_to_cart_redirect_url', $url);
 }