plugin_url() . '/assets/fonts/';
$inline_font = '@font-face {
font-family: "star";
src: url("' . $font_path . 'star.eot");
src: url("' . $font_path . 'star.eot?#iefix") format("embedded-opentype"),
url("' . $font_path . 'star.woff") format("woff"),
url("' . $font_path . 'star.ttf") format("truetype"),
url("' . $font_path . 'star.svg#star") format("svg");
font-weight: normal;
font-style: normal;
}';
wp_add_inline_style( 'blogmarks-woocommerce-style', $inline_font );
}
}
add_action( 'wp_enqueue_scripts', 'blogmarks_woocommerce_scripts' );
/**
* Add 'woocommerce-active' class to the body tag.
*
* @param array $classes CSS classes applied to the body tag.
* @return array $classes modified to include 'woocommerce-active' class.
*/
function blogmarks_woocommerce_active_body_class( $classes ) {
$classes[] = 'woocommerce-active';
if ( is_woocommerce() || is_checkout() || is_cart() || is_account_page() ) {
$classes[] = 'blogmarks-active-woocommerce-page';
}
return $classes;
}
add_filter( 'body_class', 'blogmarks_woocommerce_active_body_class' );
// Remove default wrappers.
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
// Add new wrappers for the primary section - Note ** Sidebar not included.
add_action( 'woocommerce_before_main_content', 'blogmarks_woocommerce_content_wrapper_start', 10 );
add_action( 'woocommerce_after_main_content', 'blogmarks_woocommerce_content_wrapper_end', 10 );
if ( ! function_exists( 'blogmarks_woocommerce_content_wrapper_start' ) ) {
/**
* Add a opening wrapper.
*/
function blogmarks_woocommerce_content_wrapper_start() {
echo '
';
}
}
if ( ! function_exists( 'blogmarks_woocommerce_content_wrapper_end' ) ) {
/**
* Add a closing wrapper.
*/
function blogmarks_woocommerce_content_wrapper_end() {
echo '
';
}
}
// Add main wrapper to wrap the whole content and sidebar too.
add_action( 'woocommerce_before_main_content', 'blogmarks_woocommerce_whole_wrapper_start', 5 );
// Close the wrapper after sidebar.
add_action( 'woocommerce_sidebar', 'blogmarks_woocommerce_whole_wrapper_end', 50 );
if ( ! function_exists( 'blogmarks_woocommerce_whole_wrapper_start' ) ) {
/**
* Add a opening wrapper.
*/
function blogmarks_woocommerce_whole_wrapper_start() {
echo '';
}
}
if ( ! function_exists( 'blogmarks_woocommerce_whole_wrapper_end' ) ) {
/**
* Add a closing wrapper.
*/
function blogmarks_woocommerce_whole_wrapper_end() {
echo '';
}
}
// Open a wrapper to the content of the product below the image in product listings.
add_action( 'woocommerce_shop_loop_item_title', 'blogmarks_product_details_wrapper_start', 5 );
// Close the wrapper.
add_action( 'woocommerce_after_shop_loop_item', 'blogmarks_product_details_wrapper_end', 15 );
if ( ! function_exists( 'blogmarks_product_details_wrapper_start' ) ) {
/**
* Add a opening wrapper.
*/
function blogmarks_product_details_wrapper_start() {
echo '';
}
}
if ( ! function_exists( 'blogmarks_product_details_wrapper_end' ) ) {
/**
* Add a closing wrapper.
*/
function blogmarks_product_details_wrapper_end() {
echo '
';
}
}
/*
Default image size in gallery thumbnail
*------------------------------------------*/
add_filter(
'woocommerce_gallery_thumbnail_size',
function( $size ) {
return 'woocommerce_thumbnail';
}
);
if ( ! function_exists( 'blogmarks_woocommerce_cart_link_fragment' ) ) {
/**
* Cart Fragments.
*
* Ensure cart contents update when products are added to the cart via AJAX.
*
* @param array $fragments Fragments to refresh via AJAX.
* @return array Fragments to refresh via AJAX.
*/
function blogmarks_woocommerce_cart_link_fragment( $fragments ) {
ob_start();
blogmarks_woocommerce_cart_link();
$fragments['a.cart-contents'] = ob_get_clean();
return $fragments;
}
}
add_filter( 'woocommerce_add_to_cart_fragments', 'blogmarks_woocommerce_cart_link_fragment' );
if ( ! function_exists( 'blogmarks_woocommerce_cart_link' ) ) {
/**
* Cart Link.
*
* Displayed a link to the cart including the number of items present and the cart total.
*
* @return void
*/
function blogmarks_woocommerce_cart_link() {
?>
cart->get_cart_contents_count() ); ?>
get_image();
$product_title = sprintf( __( '%s has been added to your cart.', 'blogmarks' ), '' . $product->get_title() . '' );
} else {
$product_title = __( 'Product Added to cart', 'blogmarks' );
}
ob_start();
?>