ID\"";
if ( in_array( $page->ID, (array) $args['selected'] ) ) {
$output .= ' selected="selected"';
}
$output .= '>';
$title = apply_filters( 'list_pages', $page->post_title, $page );
$output .= $pad . ' ' . esc_html( $title );
$output .= "\n";
}
}
}
if ( ! function_exists( 'woofc_init' ) ) {
add_action( 'plugins_loaded', 'woofc_init', 11 );
function woofc_init() {
if ( ! function_exists( 'WC' ) || ! version_compare( WC()->version, '3.0', '>=' ) ) {
add_action( 'admin_notices', 'woofc_notice_wc' );
return null;
}
if ( ! class_exists( 'WPCleverWoofc' ) && class_exists( 'WC_Product' ) ) {
class WPCleverWoofc {
protected static $settings = [];
protected static $localization = [];
protected static $instance = null;
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
function __construct() {
self::$settings = (array) get_option( 'woofc_settings', [] );
self::$localization = (array) get_option( 'woofc_localization', [] );
if ( empty( self::$localization ) ) {
// version < 5.2
self::$localization = (array) get_option( '_woofc_localization', [] );
}
add_action( 'init', [ $this, 'init' ] );
add_action( 'wp_footer', [ $this, 'footer' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
add_action( 'admin_init', [ $this, 'register_settings' ] );
add_action( 'admin_menu', [ $this, 'admin_menu' ] );
add_filter( 'plugin_action_links', [ $this, 'action_links' ], 10, 2 );
add_filter( 'plugin_row_meta', [ $this, 'row_meta' ], 10, 2 );
add_filter( 'wp_nav_menu_items', [ $this, 'nav_menu_items' ], 99, 2 );
add_filter( 'woocommerce_add_to_cart_fragments', [ $this, 'cart_fragment' ] );
add_filter( 'woocommerce_update_order_review_fragments', [ $this, 'cart_fragment' ] );
add_filter( 'wpcsm_locations', [ $this, 'wpcsm_locations' ] );
// shortcode
add_shortcode( 'woofc_link', [ $this, 'shortcode_cart_link' ] );
add_shortcode( 'woofc_cart_link', [ $this, 'shortcode_cart_link' ] );
// ajax
add_action( 'wc_ajax_woofc_update_qty', [ $this, 'ajax_update_qty' ] );
add_action( 'wc_ajax_woofc_remove_item', [ $this, 'ajax_remove_item' ] );
add_action( 'wc_ajax_woofc_undo_remove', [ $this, 'ajax_undo_remove' ] );
add_action( 'wc_ajax_woofc_empty_cart', [ $this, 'ajax_empty_cart' ] );
}
function init() {
// load text-domain
load_plugin_textdomain( 'woo-fly-cart', false, basename( WOOFC_DIR ) . '/languages/' );
}
public static function get_settings() {
return apply_filters( 'woofc_get_settings', self::$settings );
}
public static function get_setting( $name, $default = false ) {
if ( ! empty( self::$settings ) ) {
if ( isset( self::$settings[ $name ] ) ) {
$setting = self::$settings[ $name ];
} else {
$setting = $default;
}
} else {
$setting = get_option( '_woofc_' . $name, $default );
}
return apply_filters( 'woofc_get_setting', $setting, $name, $default );
}
public static function localization( $key = '', $default = '' ) {
$str = '';
if ( ! empty( $key ) && ! empty( self::$localization[ $key ] ) ) {
$str = self::$localization[ $key ];
} elseif ( ! empty( $default ) ) {
$str = $default;
}
return apply_filters( 'woofc_localization_' . $key, $str );
}
function enqueue_scripts() {
if ( self::disable() ) {
return null;
}
// hint css
wp_enqueue_style( 'hint', WOOFC_URI . 'assets/hint/hint.min.css' );
// perfect scrollbar
if ( apply_filters( 'woofc_perfect_scrollbar', self::get_setting( 'perfect_scrollbar', 'yes' ) ) === 'yes' ) {
wp_enqueue_style( 'perfect-scrollbar', WOOFC_URI . 'assets/perfect-scrollbar/css/perfect-scrollbar.min.css' );
wp_enqueue_style( 'perfect-scrollbar-wpc', WOOFC_URI . 'assets/perfect-scrollbar/css/custom-theme.css' );
wp_enqueue_script( 'perfect-scrollbar', WOOFC_URI . 'assets/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js', [ 'jquery' ], WOOFC_VERSION, true );
}
// slick
if ( ( ( apply_filters( 'woofc_slick', self::get_setting( 'suggested_carousel', 'yes' ), 'suggested' ) === 'yes' ) && ! empty( self::get_setting( 'suggested', [] ) ) ) || ( ( self::get_setting( 'upsell_funnel', 'yes' ) === 'yes' ) && class_exists( 'Wpcuf' ) && ( self::get_setting( 'upsell_funnel_carousel', 'yes' ) === 'yes' ) ) ) {
wp_enqueue_style( 'slick', WOOFC_URI . 'assets/slick/slick.css' );
wp_enqueue_script( 'slick', WOOFC_URI . 'assets/slick/slick.min.js', [ 'jquery' ], WOOFC_VERSION, true );
}
// main
if ( ! apply_filters( 'woofc_disable_font_icon', false ) ) {
wp_enqueue_style( 'woofc-fonts', WOOFC_URI . 'assets/css/fonts.css' );
}
// css
wp_enqueue_style( 'woofc-frontend', WOOFC_URI . 'assets/css/frontend.css', [], WOOFC_VERSION );
$color = self::get_setting( 'color', '#cc6055' );
$bg_image = self::get_setting( 'bg_image', '' ) !== '' ? wp_get_attachment_url( self::get_setting( 'bg_image', '' ) ) : '';
$inline_css = ".woofc-area.woofc-style-01 .woofc-inner, .woofc-area.woofc-style-03 .woofc-inner, .woofc-area.woofc-style-02 .woofc-area-bot .woofc-action .woofc-action-inner > div a:hover, .woofc-area.woofc-style-04 .woofc-area-bot .woofc-action .woofc-action-inner > div a:hover {
background-color: {$color};
}
.woofc-area.woofc-style-01 .woofc-area-bot .woofc-action .woofc-action-inner > div a, .woofc-area.woofc-style-02 .woofc-area-bot .woofc-action .woofc-action-inner > div a, .woofc-area.woofc-style-03 .woofc-area-bot .woofc-action .woofc-action-inner > div a, .woofc-area.woofc-style-04 .woofc-area-bot .woofc-action .woofc-action-inner > div a {
outline: none;
color: {$color};
}
.woofc-area.woofc-style-02 .woofc-area-bot .woofc-action .woofc-action-inner > div a, .woofc-area.woofc-style-04 .woofc-area-bot .woofc-action .woofc-action-inner > div a {
border-color: {$color};
}
.woofc-area.woofc-style-05 .woofc-inner{
background-color: {$color};
background-image: url('{$bg_image}');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.woofc-count span {
background-color: {$color};
}";
wp_add_inline_style( 'woofc-frontend', $inline_css );
$show_cart = 'no';
$requests = apply_filters( 'woofc_auto_show_requests', [
'add-to-cart',
'product_added_to_cart',
'added_to_cart',
'set_cart',
'fill_cart'
] );
if ( is_array( $requests ) && ! empty( $requests ) ) {
foreach ( $requests as $request ) {
if ( isset( $_REQUEST[ $request ] ) ) {
$show_cart = 'yes';
break;
}
}
}
$show_checkout = 'no';
$checkout_requests = apply_filters( 'woofc_auto_show_checkout_requests', [] );
if ( is_array( $checkout_requests ) && ! empty( $checkout_requests ) ) {
foreach ( $checkout_requests as $checkout_request ) {
if ( isset( $_REQUEST[ $checkout_request ] ) ) {
$show_checkout = 'yes';
break;
}
}
}
// js
wp_enqueue_script( 'woofc-frontend', WOOFC_URI . 'assets/js/frontend.js', [
'jquery',
'wc-cart-fragments'
], WOOFC_VERSION, true );
wp_localize_script( 'woofc-frontend', 'woofc_vars', apply_filters( 'woofc_vars', [
'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
'nonce' => wp_create_nonce( 'woofc-security' ),
'scrollbar' => self::get_setting( 'perfect_scrollbar', 'yes' ),
'auto_show' => self::get_setting( 'auto_show_ajax', 'yes' ),
'auto_show_normal' => self::get_setting( 'auto_show_normal', 'yes' ),
'show_cart' => esc_attr( $show_cart ),
'show_checkout' => esc_attr( $show_checkout ),
'delay' => (int) apply_filters( 'woofc_delay', 300 ),
'undo_remove' => self::get_setting( 'undo_remove', 'yes' ),
'confirm_remove' => self::get_setting( 'confirm_remove', 'no' ),
'instant_checkout' => self::get_setting( 'instant_checkout', 'no' ),
'instant_checkout_open' => self::get_setting( 'instant_checkout_open', 'no' ),
'confirm_empty' => self::get_setting( 'confirm_empty', 'no' ),
'confirm_empty_text' => self::localization( 'empty_confirm', esc_html__( 'Do you want to empty the cart?', 'woo-fly-cart' ) ),
'confirm_remove_text' => self::localization( 'remove_confirm', esc_html__( 'Do you want to remove this item?', 'woo-fly-cart' ) ),
'undo_remove_text' => self::localization( 'remove_undo', esc_html__( 'Undo?', 'woo-fly-cart' ) ),
'removed_text' => self::localization( 'removed', /* translators: product */ esc_html__( '%s was removed.', 'woo-fly-cart' ) ),
'manual_show' => self::get_setting( 'manual_show', '' ),
'reload' => self::get_setting( 'reload', 'no' ),
'suggested_carousel' => apply_filters( 'woofc_slick', self::get_setting( 'suggested_carousel', 'yes' ), 'suggested' ) === 'yes',
'save_for_later_carousel' => apply_filters( 'woofc_slick', self::get_setting( 'save_for_later_carousel', 'yes' ), 'save_for_later' ) === 'yes',
'upsell_funnel_carousel' => self::get_setting( 'upsell_funnel_carousel', 'yes' ) === 'yes',
'slick_params' => apply_filters( 'woofc_slick_params', json_encode( apply_filters( 'woofc_slick_params_arr', [
'slidesToShow' => 1,
'slidesToScroll' => 1,
'dots' => true,
'arrows' => false,
'autoplay' => false,
'autoplaySpeed' => 3000,
'rtl' => is_rtl()
] ) ) ),
'is_cart' => is_cart(),
'is_checkout' => is_checkout(),
'cart_url' => self::disable() ? wc_get_cart_url() : '',
'hide_count_empty' => self::get_setting( 'count_hide_empty', 'no' ),
'wc_checkout_js' => defined( 'WC_PLUGIN_FILE' ) ? plugins_url( 'assets/js/frontend/checkout.js', WC_PLUGIN_FILE ) : '',
] )
);
}
function admin_enqueue_scripts( $hook ) {
if ( apply_filters( 'woofc_ignore_backend_scripts', false, $hook ) ) {
return null;
}
wp_enqueue_style( 'woofc-backend', WOOFC_URI . 'assets/css/backend.css', [], WOOFC_VERSION );
if ( strpos( $hook, 'woofc' ) ) {
add_thickbox();
wp_enqueue_media();
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'fonticonpicker', WOOFC_URI . 'assets/fonticonpicker/css/jquery.fonticonpicker.css' );
wp_enqueue_script( 'fonticonpicker', WOOFC_URI . 'assets/fonticonpicker/js/jquery.fonticonpicker.min.js', [ 'jquery' ] );
wp_enqueue_style( 'woofc-fonts', WOOFC_URI . 'assets/css/fonts.css' );
wp_enqueue_script( 'woofc-backend', WOOFC_URI . 'assets/js/backend.js', [
'jquery',
'wp-color-picker'
] );
}
}
function action_links( $links, $file ) {
static $plugin;
if ( ! isset( $plugin ) ) {
$plugin = plugin_basename( __FILE__ );
}
if ( $plugin === $file ) {
$settings = '' . esc_html__( 'Settings', 'woo-fly-cart' ) . '';
$links['wpc-premium'] = '' . esc_html__( 'Premium Version', 'woo-fly-cart' ) . '';
array_unshift( $links, $settings );
}
return (array) $links;
}
function row_meta( $links, $file ) {
static $plugin;
if ( ! isset( $plugin ) ) {
$plugin = plugin_basename( __FILE__ );
}
if ( $plugin === $file ) {
$row_meta = [
'support' => '' . esc_html__( 'Community support', 'woo-fly-cart' ) . '',
];
return array_merge( $links, $row_meta );
}
return (array) $links;
}
function register_settings() {
// settings
register_setting( 'woofc_settings', 'woofc_settings' );
// localization
register_setting( 'woofc_localization', 'woofc_localization' );
}
function admin_menu() {
add_submenu_page( 'wpclever', esc_html__( 'WPC Fly Cart', 'woo-fly-cart' ), esc_html__( 'Fly Cart', 'woo-fly-cart' ), 'manage_options', 'wpclever-woofc', [
$this,
'admin_menu_content'
] );
}
function admin_menu_content() {
$active_tab = sanitize_key( $_GET['tab'] ?? 'settings' );
?>
' . esc_html__( 'Premium', 'woo-fly-cart' ) . '' : '' ); ?>
Get the Premium Version just $29!
https://wpclever.net/downloads/fly-cart
Extra features for Premium Version:
- - Enable coupon form.
- - Enable shipping cost and shipping calculator.
- - Enable instant checkout.
- - Get lifetime update & premium support.
Suggestion
To display custom engaging real-time messages on any wished positions, please
install
WPC
Smart Messages plugin. It's free!
cart->get_cart_item( sanitize_text_field( $_POST['cart_item_key'] ) ) ) {
$qty = (float) sanitize_text_field( $_POST['cart_item_qty'] );
if ( ( $max_purchase = $cart_item['data']->get_max_purchase_quantity() ) && ( $max_purchase > 0 ) && ( $qty > $max_purchase ) ) {
$qty = $max_purchase;
}
if ( $qty > 0 ) {
WC()->cart->set_quantity( sanitize_text_field( $_POST['cart_item_key'] ), $qty );
} else {
WC()->cart->remove_cart_item( sanitize_text_field( $_POST['cart_item_key'] ) );
}
}
wp_send_json( [ 'action' => 'update_qty' ] );
}
wp_die();
}
function ajax_remove_item() {
if ( ! apply_filters( 'woofc_disable_security_check', false, 'remove_item' ) ) {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'woofc-security' ) ) {
die( 'Permissions check failed!' );
}
}
if ( isset( $_POST['cart_item_key'] ) ) {
WC()->cart->remove_cart_item( sanitize_text_field( $_POST['cart_item_key'] ) );
WC_AJAX::get_refreshed_fragments();
}
wp_die();
}
function ajax_undo_remove() {
if ( ! apply_filters( 'woofc_disable_security_check', false, 'undo_remove' ) ) {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'woofc-security' ) ) {
die( 'Permissions check failed!' );
}
}
if ( isset( $_POST['item_key'] ) ) {
if ( WC()->cart->restore_cart_item( sanitize_text_field( $_POST['item_key'] ) ) ) {
echo 'true';
} else {
echo 'false';
}
}
wp_die();
}
function ajax_empty_cart() {
if ( ! apply_filters( 'woofc_disable_security_check', false, 'empty_cart' ) ) {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'woofc-security' ) ) {
die( 'Permissions check failed!' );
}
}
WC()->cart->empty_cart();
WC_AJAX::get_refreshed_fragments();
wp_die();
}
function get_cart_area() {
if ( ! isset( WC()->cart ) ) {
return '';
}
// settings
$link = self::get_setting( 'link', 'yes' );
$plus_minus = self::get_setting( 'plus_minus', 'yes' ) === 'yes';
$remove = self::get_setting( 'remove', 'yes' ) === 'yes';
$suggested = self::get_setting( 'suggested', [] );
$suggested_products = $cart_products = [];
// backward compatibility before 5.2.2
if ( ! is_array( $suggested ) ) {
switch ( (string) $suggested ) {
case 'cross_sells':
$suggested = [ 'cross_sells' ];
break;
case 'related':
$suggested = [ 'related' ];
break;
case 'both':
$suggested = [ 'related', 'cross_sells' ];
break;
case 'none':
$suggested = [];
break;
default:
$suggested = [];
}
}
if ( in_array( 'wishlist', $suggested ) && class_exists( 'WPCleverWoosw' ) ) {
$suggested_products = array_merge( $suggested_products, array_keys( WPCleverWoosw::get_products() ) );
}
if ( in_array( 'compare', $suggested ) && class_exists( 'WPCleverWoosc' ) ) {
if ( method_exists( 'WPCleverWoosc', 'get_products' ) ) {
// from woosc 6.1.4
$compare_products = WPCleverWoosc::get_products();
$suggested_products = array_merge( $suggested_products, $compare_products );
} else {
$cookie = 'woosc_products_' . md5( 'woosc' . get_current_user_id() );
if ( ! empty( $_COOKIE[ $cookie ] ) ) {
$compare_products = explode( ',', sanitize_text_field( $_COOKIE[ $cookie ] ) );
$suggested_products = array_merge( $suggested_products, $compare_products );
}
}
}
ob_start();
// global product
global $product;
$global_product = $product;
echo '';
do_action( 'woofc_above_area' );
echo apply_filters( 'woofc_above_area_content', '' );
echo '
' . self::localization( 'heading', esc_html__( 'Shopping cart', 'woo-fly-cart' ) ) . '' . WC()->cart->get_cart_contents_count() . '';
if ( self::get_setting( 'close', 'yes' ) === 'yes' ) {
echo '
';
}
echo '
';
echo '
';
do_action( 'woofc_above_items' );
echo apply_filters( 'woofc_above_items_content', '' );
// notices
if ( apply_filters( 'woofc_show_notices', true ) ) {
$notices = wc_print_notices( true );
if ( ! empty( $notices ) ) {
echo '
' . $notices . '
';
}
}
$items = WC()->cart->get_cart();
if ( is_array( $items ) && ( count( $items ) > 0 ) ) {
if ( apply_filters( 'woofc_cart_items_reverse', self::get_setting( 'reverse_items', 'yes' ) === 'yes' ) ) {
$items = array_reverse( $items );
}
foreach ( $items as $cart_item_key => $cart_item ) {
if ( ! isset( $cart_item['bundled_by'] ) && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
$product_link = apply_filters( 'woocommerce_cart_item_permalink', $product->is_visible() ? $product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
$item_class = $remove ? 'woofc-item woofc-item-has-remove' : 'woofc-item woofc-item-has-not-remove';
// add suggested products
if ( is_array( $suggested ) && ! empty( $suggested ) ) {
$cart_products[] = $product_id;
if ( in_array( 'related', $suggested ) ) {
$suggested_products = array_merge( $suggested_products, wc_get_related_products( $product_id ) );
}
if ( in_array( 'cross_sells', $suggested ) ) {
$suggested_products = array_merge( $suggested_products, $product->get_cross_sell_ids() );
}
if ( in_array( 'up_sells', $suggested ) ) {
$suggested_products = array_merge( $suggested_products, $product->get_upsell_ids() );
}
}
echo '
';
do_action( 'woofc_above_item', $cart_item );
echo apply_filters( 'woofc_above_item_inner', '', $cart_item );
echo '
';
echo '
';
if ( ( $link !== 'no' ) && ! empty( $product_link ) ) {
$cart_item_thumbnail = sprintf( '
%s', esc_url( $product_link ), $product->get_image() );
} else {
$cart_item_thumbnail = $product->get_image();
}
echo apply_filters( 'woocommerce_cart_item_thumbnail', $cart_item_thumbnail, $cart_item, $cart_item_key );
echo '
';
echo '
';
do_action( 'woofc_above_item_info', $product, $cart_item );
//echo apply_filters( 'woofc_above_item_info', '', $product, $cart_item );
do_action( 'woofc_above_item_name', $product, $cart_item );
echo '
';
if ( ( $link !== 'no' ) && ! empty( $product_link ) ) {
$cart_item_name = sprintf( '%s', esc_url( $product_link ), $product->get_name() );
} else {
$cart_item_name = $product->get_name();
}
echo apply_filters( 'woocommerce_cart_item_name', $cart_item_name, $cart_item, $cart_item_key );
echo '';
do_action( 'woofc_below_item_name', $product, $cart_item );
if ( self::get_setting( 'data', 'no' ) === 'yes' ) {
echo apply_filters( 'woofc_cart_item_data', '
' . wc_get_formatted_cart_item_data( $cart_item, apply_filters( 'woofc_cart_item_data_flat', true ) ) . '', $cart_item );
}
if ( self::get_setting( 'price', 'price' ) === 'price' ) {
echo '
' . apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $product ), $cart_item, $cart_item_key ) . '';
} elseif ( self::get_setting( 'price', 'price' ) === 'subtotal' ) {
echo '
' . apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $product, $cart_item['quantity'] ), $cart_item, $cart_item_key ) . '';
}
if ( ( self::get_setting( 'estimated_delivery_date', 'no' ) === 'yes' ) && class_exists( 'WPCleverWpced' ) ) {
echo apply_filters( 'woofc_cart_item_estimated_delivery_date', '
' . do_shortcode( '[wpced]' ) . '', $cart_item );
}
if ( ( self::get_setting( 'save_for_later', 'yes' ) === 'yes' ) && class_exists( 'WPCleverWoosl' ) ) {
if ( $cart_item['data']->is_type( 'variation' ) && is_array( $cart_item['variation'] ) ) {
$variation = htmlspecialchars( json_encode( $cart_item['variation'] ), ENT_QUOTES, 'UTF-8' );
} else {
$variation = '';
}
echo '
' . do_shortcode( '[woosl_btn product_id="' . $cart_item['product_id'] . '" variation_id="' . $cart_item['variation_id'] . '" price="' . $cart_item['data']->get_price() . '" variation="' . $variation . '" cart_item_key="' . $cart_item_key . '" context="woofc"]' ) . '';
}
do_action( 'woofc_below_item_info', $product, $cart_item );
//echo apply_filters( 'woofc_below_item_info', '', $product, $cart_item );
echo '
';
$min_value = apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product );
$max_value = apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product );
if ( $product->is_sold_individually() || ( $max_value && $min_value === $max_value ) || ! empty( $cart_item['woosb_parent_id'] ) || ! empty( $cart_item['wooco_parent_id'] ) || ! empty( $cart_item['woofs_parent_id'] ) ) {
$cart_item_quantity = $cart_item['quantity'];
} else {
$cart_item_qty = isset( $cart_item['quantity'] ) ? wc_stock_amount( wp_unslash( $cart_item['quantity'] ) ) : $product->get_min_purchase_quantity();
$cart_item_quantity_input = woocommerce_quantity_input( [
'classes' => [ 'input-text', 'woofc-qty', 'qty', 'text' ],
'input_name' => 'woofc_qty_' . $cart_item_key,
'input_value' => $cart_item_qty,
'min_value' => $min_value,
'max_value' => $max_value,
'woofc_qty' => [
'input_value' => $cart_item_qty,
'min_value' => $min_value,
'max_value' => $max_value
]
], $product, false );
if ( $plus_minus ) {
$cart_item_quantity = '
-' . $cart_item_quantity_input . '
+';
} else {
$cart_item_quantity = $cart_item_quantity_input;
}
}
echo '
' . apply_filters( 'woocommerce_cart_item_quantity', $cart_item_quantity, $cart_item_key, $cart_item ) . '
';
// always keep .woofc-item-remove to compatible with themes - can hide it by CSS
echo apply_filters( 'woocommerce_cart_item_remove_link', '
', $cart_item_key );
echo '
';
do_action( 'woofc_below_item', $cart_item );
echo apply_filters( 'woofc_below_item_inner', '', $cart_item );
echo '
';
}
}
} else {
echo '
' . wp_kses_post( apply_filters( 'woofc_empty_message', self::localization( 'no_products', esc_html__( 'There are no products in the cart!', 'woo-fly-cart' ) ) ) ) . '
';
if ( ( self::get_setting( 'save_for_later', 'yes' ) === 'yes' ) && class_exists( 'WPCleverWoosl' ) ) {
echo '
' . do_shortcode( '[woosl_list context="woofc"]' ) . '
';
}
$suggested_empty = self::get_setting( 'suggested_empty', 'no' );
if ( $suggested_empty !== 'no' ) {
$suggested_empty_args = [
'status' => 'publish',
'limit' => (int) self::get_setting( 'suggested_limit', 10 ),
'return' => 'ids',
];
switch ( $suggested_empty ) {
case 'recent':
$suggested_empty_args['orderby'] = 'ID';
$suggested_empty_args['order'] = 'DESC';
break;
case 'onsale':
$suggested_empty_args['include'] = wc_get_product_ids_on_sale();
break;
case 'featured':
$suggested_empty_args['include'] = wc_get_featured_product_ids();
break;
case 'random':
$suggested_empty_args['orderby'] = 'rand';
break;
}
$suggested_empty_products = wc_get_products( apply_filters( 'woofc_suggested_empty_args', $suggested_empty_args ) );
$suggested_empty_products = apply_filters( 'woofc_suggested_empty_products', $suggested_empty_products );
if ( is_array( $suggested_empty_products ) && ! empty( $suggested_empty_products ) ) {
self::get_suggested_products( $suggested_empty_products, $link );
}
}
}
do_action( 'woofc_below_items' );
echo apply_filters( 'woofc_below_items_content', '' );
echo '
';
echo '
';
do_action( 'woofc_above_bottom' );
echo apply_filters( 'woofc_above_bottom_content', '' );
if ( ! empty( $items ) ) {
if ( self::get_setting( 'empty', 'no' ) === 'yes' || self::get_setting( 'share', 'yes' ) === 'yes' ) {
// enable empty or share
echo '
';
if ( self::get_setting( 'empty', 'no' ) === 'yes' ) {
echo '
' . self::localization( 'empty', esc_html__( 'Empty cart', 'woo-fly-cart' ) ) . '
';
}
if ( self::get_setting( 'share', 'yes' ) === 'yes' ) {
echo '
' . self::localization( 'share', esc_html__( 'Share cart', 'woo-fly-cart' ) ) . '
';
}
echo '
';
}
if ( self::get_setting( 'subtotal', 'yes' ) === 'yes' ) {
echo apply_filters( 'woofc_above_subtotal_content', '' );
echo '
' . self::localization( 'subtotal', esc_html__( 'Subtotal', 'woo-fly-cart' ) ) . '
' . apply_filters( 'woofc_get_subtotal', WC()->cart->get_cart_subtotal() ) . '
';
echo apply_filters( 'woofc_below_subtotal_content', '' );
}
if ( class_exists( 'WPCleverWpcfb' ) && ( self::get_setting( 'free_shipping_bar', 'yes' ) === 'yes' ) ) {
echo '
' . do_shortcode( '[wpcfb]' ) . '
';
}
if ( self::get_setting( 'total', 'yes' ) === 'yes' ) {
echo apply_filters( 'woofc_above_total_content', '' );
echo '
' . self::localization( 'total', esc_html__( 'Total', 'woo-fly-cart' ) ) . '
' . apply_filters( 'woofc_get_total', WC()->cart->get_total() ) . '
';
echo apply_filters( 'woofc_below_total_content', '' );
}
do_action( 'woofc_above_buttons' );
if ( self::get_setting( 'buttons', '01' ) === '01' ) {
// both buttons
echo '
';
} else {
if ( self::get_setting( 'buttons', '01' ) === '02' ) {
// cart
echo '
';
}
if ( self::get_setting( 'buttons', '01' ) === '03' ) {
// checkout
echo '
';
}
}
do_action( 'woofc_below_buttons' );
if ( ( self::get_setting( 'save_for_later', 'yes' ) === 'yes' ) && class_exists( 'WPCleverWoosl' ) ) {
echo '
' . do_shortcode( '[woosl_list context="woofc"]' ) . '
';
}
if ( ! empty( $suggested ) ) {
$suggested_products = array_unique( $suggested_products );
$suggested_products = apply_filters( 'woofc_suggested_products_before_limit', array_diff( $suggested_products, $cart_products ), $suggested_products, $cart_products );
if ( $suggested_limit = (int) self::get_setting( 'suggested_limit', 10 ) ) {
$suggested_products = array_slice( $suggested_products, 0, $suggested_limit );
}
$suggested_products = apply_filters( 'woofc_suggested_products', $suggested_products, $cart_products );
if ( ! empty( $suggested_products ) ) {
self::get_suggested_products( $suggested_products, $link );
}
}
if ( self::get_setting( 'upsell_funnel', 'yes' ) === 'yes' && class_exists( 'Wpcuf' ) ) {
echo '
' . do_shortcode( '[wpcuf_uf]' ) . '
';
}
}
if ( self::get_setting( 'continue', 'yes' ) === 'yes' ) {
echo '
' . self::localization( 'continue', esc_html__( 'Continue shopping', 'woo-fly-cart' ) ) . '
';
}
do_action( 'woofc_below_bottom' );
echo apply_filters( 'woofc_below_bottom_content', '' );
echo '
';
do_action( 'woofc_below_area' );
echo apply_filters( 'woofc_below_area_content', '' );
echo '
';
$product = $global_product;
return apply_filters( 'woofc_cart_area', ob_get_clean() );
}
function get_suggested_products( $suggested_products = [], $link = 'no' ) {
do_action( 'woofc_above_suggested', $suggested_products );
echo apply_filters( 'woofc_above_suggested_content', '' );
echo '';
echo '
' . self::localization( 'suggested', esc_html__( 'You may be interested in…', 'woo-fly-cart' ) ) . '
';
echo '
';
foreach ( $suggested_products as $suggested_product_id ) {
$suggested_product = wc_get_product( $suggested_product_id );
if ( $suggested_product ) {
$suggested_product_link = $suggested_product->is_visible() ? $suggested_product->get_permalink() : '';
echo '
';
echo '
';
if ( ( $link !== 'no' ) && ! empty( $suggested_product_link ) ) {
echo sprintf( '
%s', esc_url( $suggested_product_link ), $suggested_product->get_image() );
} else {
echo $suggested_product->get_image();
}
echo '
';
echo '
';
echo '
';
if ( ( $link !== 'no' ) && ! empty( $suggested_product_link ) ) {
echo sprintf( '
%s', esc_url( $suggested_product_link ), $suggested_product->get_name() );
} else {
echo $suggested_product->get_name();
}
echo '
';
echo '
' . $suggested_product->get_price_html() . '
';
echo '
' . do_shortcode( '[add_to_cart style="" show_price="false" id="' . esc_attr( $suggested_product->get_id() ) . '"]' ) . '
';
echo '
';
echo '
';
}
}
echo '
';
echo apply_filters( 'woofc_below_suggested_content', '' );
do_action( 'woofc_below_suggested', $suggested_products );
}
function get_cart_count() {
if ( ! isset( WC()->cart ) ) {
return '';
}
$count = WC()->cart->get_cart_contents_count();
$icon = self::get_setting( 'count_icon', 'woofc-icon-cart7' );
$count_class = 'woofc-count woofc-count-' . $count . ' woofc-count-' . self::get_setting( 'count_position', 'bottom-left' );
if ( ( self::get_setting( 'count_hide_empty', 'no' ) === 'yes' ) && ( $count <= 0 ) ) {
$count_class .= ' woofc-count-hide-empty';
}
$cart_count = '';
$cart_count .= '';
$cart_count .= '' . esc_attr( $count ) . '';
$cart_count .= '
';
return apply_filters( 'woofc_cart_count', $cart_count, $count, $icon );
}
function get_cart_menu() {
if ( ! isset( WC()->cart ) ) {
return '';
}
$count = WC()->cart->get_cart_contents_count();
$subtotal = WC()->cart->get_cart_subtotal();
$icon = self::get_setting( 'count_icon', 'woofc-icon-cart7' );
$cart_menu = '';
return apply_filters( 'woofc_cart_menu', $cart_menu, $count, $subtotal, $icon );
}
function nav_menu_items( $items, $args ) {
$selected = false;
$saved_menus = self::get_setting( 'menus', [] );
if ( ! is_array( $saved_menus ) || empty( $saved_menus ) || ! property_exists( $args, 'menu' ) ) {
return $items;
}
if ( $args->menu instanceof WP_Term ) {
// menu object
if ( in_array( $args->menu->term_id, $saved_menus, false ) ) {
$selected = true;
}
} elseif ( is_numeric( $args->menu ) ) {
// menu id
if ( in_array( $args->menu, $saved_menus, false ) ) {
$selected = true;
}
} elseif ( is_string( $args->menu ) ) {
// menu slug or name
$menu = get_term_by( 'name', $args->menu, 'nav_menu' );
if ( ! $menu ) {
$menu = get_term_by( 'slug', $args->menu, 'nav_menu' );
}
if ( $menu && in_array( $menu->term_id, $saved_menus ) ) {
$selected = true;
}
}
if ( $selected ) {
$items .= self::get_cart_menu();
}
return $items;
}
function footer() {
if ( self::disable() ) {
return null;
}
// use 'woofc-position-' instead of 'woofc-effect-' from 5.3
$area_class = apply_filters( 'woofc_area_class', 'woofc-area woofc-position-' . esc_attr( self::get_setting( 'position', '05' ) ) . ' woofc-effect-' . esc_attr( self::get_setting( 'position', '05' ) ) . ' woofc-slide-' . esc_attr( self::get_setting( 'effect', 'yes' ) ) . ' woofc-rounded-' . esc_attr( self::get_setting( 'rounded', 'no' ) ) . ' woofc-style-' . esc_attr( self::get_setting( 'style', '01' ) ) );
echo '';
echo self::get_cart_area();
echo '
';
if ( self::get_setting( 'count', 'yes' ) === 'yes' ) {
echo self::get_cart_count();
}
if ( self::get_setting( 'overlay_layer', 'yes' ) === 'yes' ) {
echo '';
}
}
function disable() {
global $wp_query;
$disable = false;
if ( $current_page = $wp_query->get_queried_object_id() ) {
$hide_pages = self::get_setting( 'hide_pages', [] );
if ( isset( self::$settings['hide_cart_checkout'] ) && ( self::$settings['hide_cart_checkout'] === 'yes' ) ) {
$hide_pages[] = wc_get_page_id( 'cart' );
$hide_pages[] = wc_get_page_id( 'checkout' );
}
if ( ! empty( $hide_pages ) && in_array( $current_page, $hide_pages ) ) {
// hide on selected pages
$disable = true;
}
}
return apply_filters( 'woofc_disable', $disable );
}
function cart_fragment( $fragments ) {
$fragments['.woofc-count'] = self::get_cart_count();
$fragments['.woofc-menu-item'] = self::get_cart_menu();
$fragments['.woofc-cart-link'] = self::get_cart_link();
$fragments['.woofc-cart-area'] = self::get_cart_area();
return $fragments;
}
function wpcsm_locations( $locations ) {
$locations['WPC Fly Cart'] = [
'woofc_above_area' => esc_html__( 'Before cart', 'woo-fly-cart' ),
'woofc_below_area' => esc_html__( 'After cart', 'woo-fly-cart' ),
'woofc_above_items' => esc_html__( 'Before cart items', 'woo-fly-cart' ),
'woofc_below_items' => esc_html__( 'After cart items', 'woo-fly-cart' ),
'woofc_above_item' => esc_html__( 'Before cart item', 'woo-fly-cart' ),
'woofc_below_item' => esc_html__( 'After cart item', 'woo-fly-cart' ),
'woofc_above_item_info' => esc_html__( 'Before cart item info', 'woo-fly-cart' ),
'woofc_below_item_info' => esc_html__( 'After cart item info', 'woo-fly-cart' ),
'woofc_above_item_name' => esc_html__( 'Before cart item name', 'woo-fly-cart' ),
'woofc_below_item_name' => esc_html__( 'After cart item name', 'woo-fly-cart' ),
'woofc_above_suggested' => esc_html__( 'Before suggested products', 'woo-fly-cart' ),
'woofc_below_suggested' => esc_html__( 'After suggested products', 'woo-fly-cart' ),
'woofc_above_buttons' => esc_html__( 'Before buttons', 'woo-fly-cart' ),
'woofc_below_buttons' => esc_html__( 'After buttons', 'woo-fly-cart' ),
];
return $locations;
}
function shortcode_cart_link() {
return apply_filters( 'woofc_shortcode_cart_link', self::get_cart_link() );
}
public static function get_cart_link( $echo = false ) {
if ( ! isset( WC()->cart ) ) {
return '';
}
$count = WC()->cart->get_cart_contents_count();
$subtotal = WC()->cart->get_cart_subtotal();
$icon = self::get_setting( 'count_icon', 'woofc-icon-cart7' );
$cart_link = ' ' . $subtotal . '';
$cart_link = apply_filters( 'woofc_cart_link', $cart_link, $count, $subtotal, $icon );
if ( $echo ) {
echo $cart_link;
} else {
return $cart_link;
}
return null;
}
public static function woofc_get_cart_link( $echo = false ) {
self::get_cart_link( $echo );
}
}
return WPCleverWoofc::instance();
}
return null;
}
}
if ( ! function_exists( 'woofc_notice_wc' ) ) {
function woofc_notice_wc() {
?>
WPC Fly Cart requires WooCommerce version 3.0 or greater.