updated plugin GP Premium
version 2.0.3
This commit is contained in:
@ -675,8 +675,10 @@ add_filter( 'woocommerce_add_to_cart_fragments', 'generatepress_wc_cart_link_fra
|
||||
function generatepress_wc_cart_link_fragment( $fragments ) {
|
||||
global $woocommerce;
|
||||
|
||||
$fragments['.cart-contents span.amount'] = ( WC()->cart->subtotal > 0 ) ? '<span class="amount">' . wp_kses_data( WC()->cart->get_cart_subtotal() ) . '</span>' : '<span class="amount"></span>';
|
||||
$fragments['.cart-contents span.number-of-items'] = ( WC()->cart->get_cart_contents_count() > 0 ) ? '<span class="number-of-items">' . wp_kses_data( WC()->cart->get_cart_contents_count() ) . '</span>' : '<span class="number-of-items no-items"></span>';
|
||||
if ( isset( WC()->cart ) ) {
|
||||
$fragments['.cart-contents span.amount'] = ( WC()->cart->subtotal > 0 ) ? '<span class="amount">' . wp_kses_data( WC()->cart->get_cart_subtotal() ) . '</span>' : '<span class="amount"></span>';
|
||||
$fragments['.cart-contents span.number-of-items'] = ( WC()->cart->get_cart_contents_count() > 0 ) ? '<span class="number-of-items">' . wp_kses_data( WC()->cart->get_cart_contents_count() ) . '</span>' : '<span class="number-of-items no-items"></span>';
|
||||
}
|
||||
|
||||
return $fragments;
|
||||
}
|
||||
@ -1054,6 +1056,9 @@ function generatepress_wc_css() {
|
||||
if ( '' !== generatepress_wc_get_setting( 'mobile_columns_gap' ) ) {
|
||||
$css->add_property( 'grid-gap', generatepress_wc_get_setting( 'mobile_columns_gap' ), false, 'px' );
|
||||
}
|
||||
|
||||
$css->set_selector( '.woocommerce #content div.product div.images,.woocommerce div.product div.images,.woocommerce-page #content div.product div.images,.woocommerce-page div.product div.images' );
|
||||
$css->add_property( 'width', '100%' );
|
||||
$css->stop_media_query();
|
||||
|
||||
$using_flex = false;
|
||||
@ -1135,8 +1140,7 @@ function generatepress_wc_product_has_gallery( $classes ) {
|
||||
$post_type = get_post_type( get_the_ID() );
|
||||
|
||||
if ( 'product' === $post_type && method_exists( 'WC_Product', 'get_gallery_image_ids' ) ) {
|
||||
|
||||
$product = new WC_Product( get_the_ID() );
|
||||
$product = wc_get_product( get_the_ID() );
|
||||
$attachment_ids = $product->get_gallery_image_ids();
|
||||
|
||||
if ( $attachment_ids && generatepress_wc_get_setting( 'product_secondary_image' ) && generatepress_wc_get_setting( 'product_archive_image' ) && has_post_thumbnail() ) {
|
||||
@ -1157,7 +1161,7 @@ function generatepress_wc_secondary_product_image() {
|
||||
$post_type = get_post_type( get_the_ID() );
|
||||
|
||||
if ( 'product' === $post_type && method_exists( 'WC_Product', 'get_gallery_image_ids' ) ) {
|
||||
$product = new WC_Product( get_the_ID() );
|
||||
$product = wc_get_product( get_the_ID() );
|
||||
$attachment_ids = $product->get_gallery_image_ids();
|
||||
|
||||
if ( $attachment_ids && generatepress_wc_get_setting( 'product_secondary_image' ) && generatepress_wc_get_setting( 'product_archive_image' ) && has_post_thumbnail() ) {
|
||||
@ -1257,13 +1261,27 @@ function generatepress_wc_add_to_cart_helper() {
|
||||
</div>
|
||||
|
||||
<div class="cart-data">
|
||||
<?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'gp-premium' ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?>
|
||||
<?php
|
||||
if ( isset( WC()->cart ) ) {
|
||||
echo sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'gp-premium' ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkout">
|
||||
<a href="<?php echo wc_get_checkout_url(); ?>" class="button"><?php _e( 'Checkout', 'gp-premium' ); ?></a>
|
||||
</div>
|
||||
<?php
|
||||
// phpcs:ignore -- No need to escape full thing.
|
||||
echo apply_filters(
|
||||
'generate_wc_cart_panel_checkout_button_output',
|
||||
sprintf(
|
||||
'<div class="checkout">
|
||||
<a href="%s" class="button">%s</a>
|
||||
</div>',
|
||||
esc_url( wc_get_checkout_url() ),
|
||||
esc_html__( 'Checkout', 'gp-premium' )
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
@ -1287,31 +1305,46 @@ function generatepress_wc_add_to_cart_helper() {
|
||||
<div class="product-price">
|
||||
<?php echo $product->get_price_html(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $product->is_type( 'simple' ) ) : ?>
|
||||
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart<?php echo $quantity_buttons; ?>" method="post" enctype="multipart/form-data">
|
||||
<?php
|
||||
$args = array(
|
||||
'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 ),
|
||||
);
|
||||
|
||||
echo woocommerce_quantity_input( $args, $product, false );
|
||||
?>
|
||||
<button type="submit" class="button alt"><?php echo esc_html( $product->add_to_cart_text() ); ?></button>
|
||||
</form>
|
||||
<?php endif;
|
||||
|
||||
if ( $product->is_type( 'variable' ) ) : ?>
|
||||
<button type="submit" class="button alt go-to-variables"><?php echo esc_html( $product->add_to_cart_text() ); ?></button>
|
||||
<?php endif;
|
||||
$action = '';
|
||||
|
||||
if ( $product->is_type( 'external' ) ) : ?>
|
||||
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart" method="post" enctype="multipart/form-data">
|
||||
<button type="submit" class="button alt"><?php echo esc_html( $product->add_to_cart_text() ); ?></button>
|
||||
</form>
|
||||
<?php endif;
|
||||
if ( $product->is_type( 'simple' ) ) {
|
||||
$args = array(
|
||||
'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 ),
|
||||
);
|
||||
|
||||
$action = sprintf(
|
||||
'<form action="%1$s" class="cart%2$s" method="post" enctype="multipart/form-data">
|
||||
%3$s
|
||||
<button type="submit" class="button alt">%4$s</button>
|
||||
</form>',
|
||||
esc_url( $product->add_to_cart_url() ),
|
||||
$quantity_buttons,
|
||||
woocommerce_quantity_input( $args, $product, false ),
|
||||
esc_html( $product->add_to_cart_text() )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $product->is_type( 'variable' ) ) {
|
||||
$action = sprintf(
|
||||
'<button type="submit" class="button alt go-to-variables">%s</button>',
|
||||
esc_html( $product->add_to_cart_text() )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $product->is_type( 'external' ) ) {
|
||||
$action = sprintf(
|
||||
'<form action="%1$s" class="cart" method="post" enctype="multipart/form-data">
|
||||
<button type="submit" class="button alt">%2$s</button>
|
||||
</form>',
|
||||
esc_url( $product->add_to_cart_url() ),
|
||||
esc_html( $product->add_to_cart_text() )
|
||||
);
|
||||
}
|
||||
|
||||
echo apply_filters( 'generate_wc_sticky_add_to_cart_action', $action, $product ); // phpcs:ignore -- No escaping needed.
|
||||
endif;
|
||||
?>
|
||||
|
||||
@ -1327,7 +1360,9 @@ add_filter( 'woocommerce_add_to_cart_fragments', 'generatepress_add_to_cart_pane
|
||||
* @since 1.8
|
||||
*/
|
||||
function generatepress_add_to_cart_panel_fragments( $fragments ) {
|
||||
$fragments['.add-to-cart-panel .cart-data'] = '<div class="cart-data">' . sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'gp-premium' ), WC()->cart->get_cart_contents_count() ) . ' - ' . WC()->cart->get_cart_total() . '</div>';
|
||||
if ( isset( WC()->cart ) ) {
|
||||
$fragments['.add-to-cart-panel .cart-data'] = '<div class="cart-data">' . sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'gp-premium' ), WC()->cart->get_cart_contents_count() ) . ' - ' . WC()->cart->get_cart_total() . '</div>';
|
||||
}
|
||||
|
||||
return $fragments;
|
||||
}
|
||||
@ -1353,7 +1388,7 @@ function generatepress_wc_show_sticky_add_to_cart() {
|
||||
$show = true;
|
||||
}
|
||||
|
||||
return $show;
|
||||
return apply_filters( 'generate_wc_show_sticky_add_to_cart', $show );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user