,
'wp-element-button',
'wc-block-components-product-button__button',
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$is_ajax_button ? 'ajax_add_to_cart' : '',
'product_type_' . $product->get_type(),
esc_attr( $styles_and_classes['classes'] ),
)
)
);
$default_quantity = 1;
/**
* Filters the change the quantity to add to cart.
*
* @since 10.9.0
* @param number $default_quantity The default quantity.
* @param number $product_id The product id.
*/
$quantity_to_add = apply_filters( 'woocommerce_add_to_cart_quantity', $default_quantity, $product->get_id() );
$context = array(
'quantityToAdd' => $quantity_to_add,
'productId' => $product->get_id(),
'addToCartText' => null !== $product->add_to_cart_text() ? $product->add_to_cart_text() : __( 'Add to cart', 'woocommerce' ),
'temporaryNumberOfItems' => $number_of_items_in_cart,
'animationStatus' => 'IDLE',
);
/**
* Allow filtering of the add to cart button arguments.
*
* @since 9.7.0
*/
$args = apply_filters(
'woocommerce_loop_add_to_cart_args',
array(
'class' => $html_classes,
'attributes' => array(
'data-product_id' => $product->get_id(),
'data-product_sku' => $product->get_sku(),
'aria-label' => $product->add_to_cart_description(),
'rel' => 'nofollow',
),
),
$product
);
if ( isset( $args['attributes']['aria-label'] ) ) {
$args['attributes']['aria-label'] = wp_strip_all_tags( $args['attributes']['aria-label'] );
}
if ( isset( WC()->cart ) && ! WC()->cart->is_empty() ) {
$this->prevent_cache();
}
$interactive = array(
'namespace' => 'woocommerce/product-button',
);
$div_directives = '
data-wc-interactive=\'' . wp_json_encode( $interactive, JSON_NUMERIC_CHECK | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ) . '\'
data-wc-context=\'' . wp_json_encode( $context, JSON_NUMERIC_CHECK | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ) . '\'
';
$button_directives = '
data-wc-on--click="actions.addToCart"
data-wc-class--loading="context.isLoading"
';
$anchor_directive = '
data-wc-on--click="woocommerce/product-collection::actions.viewProduct"
';
$span_button_directives = '
data-wc-text="state.addToCartText"
data-wc-class--wc-block-slide-in="state.slideInAnimation"
data-wc-class--wc-block-slide-out="state.slideOutAnimation"
data-wc-on--animationend="actions.handleAnimationEnd"
data-wc-watch="callbacks.startAnimation"
data-wc-layout-init="callbacks.syncTemporaryNumberOfItemsOnLoad"
';
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => implode(
' ',
array_filter(
[
'wp-block-button wc-block-components-product-button',
esc_attr( $classname . ' ' . $custom_width_classes . ' ' . $custom_align_classes ),
]
)
),
)
);
/**
* Filters the add to cart button class.
*
* @since 8.7.0
*
* @param string $class The class.
*/
return apply_filters(
'woocommerce_loop_add_to_cart_link',
strtr(
'
<{html_element}
href="{add_to_cart_url}"
class="{button_classes}"
style="{button_styles}"
{attributes}
{button_directives}
>
{add_to_cart_text}
{html_element}>
{view_cart_html}
',
array(
'{wrapper_attributes}' => $wrapper_attributes,
'{html_element}' => $html_element,
'{add_to_cart_url}' => esc_url( $product->add_to_cart_url() ),
'{button_classes}' => isset( $args['class'] ) ? esc_attr( $args['class'] . ' wc-interactive' ) : 'wc-interactive',
'{button_styles}' => esc_attr( $styles_and_classes['styles'] ),
'{attributes}' => isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
'{add_to_cart_text}' => esc_html( $initial_product_text ),
'{div_directives}' => $is_ajax_button ? $div_directives : '',
'{button_directives}' => $is_ajax_button ? $button_directives : $anchor_directive,
'{span_button_directives}' => $is_ajax_button ? $span_button_directives : '',
'{view_cart_html}' => $is_ajax_button ? $this->get_view_cart_html() : '',
)
),
$product,
$args
);
}
}
/**
* Get the number of items in the cart for a given product id.
*
* @param number $product_id The product id.
* @return number The number of items in the cart.
*/
private function get_cart_item_quantities_by_product_id( $product_id ) {
if ( ! isset( WC()->cart ) ) {
return 0;
}
$cart = WC()->cart->get_cart_item_quantities();
return isset( $cart[ $product_id ] ) ? $cart[ $product_id ] : 0;
}
/**
* Prevent caching on certain pages
*/
private function prevent_cache() {
\WC_Cache_Helper::set_nocache_constants();
nocache_headers();
}
/**
* Get the view cart link html.
*
* @return string The view cart html.
*/
private function get_view_cart_html() {
return sprintf(
'
%3$s
',
esc_url( wc_get_cart_url() ),
esc_attr__( 'View cart', 'woocommerce' ),
esc_html__( 'View cart', 'woocommerce' )
);
}
}
Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Blocks\BlockTypes\ProductButton' not found in /home/htzanetatos/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php:154
Stack trace:
#0 /home/htzanetatos/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\BlockTypesController->register_blocks('')
#1 /home/htzanetatos/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#2 /home/htzanetatos/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#3 /home/htzanetatos/public_html/wp-settings.php(704): do_action('init')
#4 /home/htzanetatos/public_html/wp-config.php(83): require_once('/home/htzanetat...')
#5 /home/htzanetatos/public_html/wp-load.php(50): require_once('/home/htzanetat...')
#6 /home/htzanetatos/public_html/wp-blog-header.php(13): require_once('/home/htzanetat...')
#7 /home/htzanetatos/public_html/index.php(17): require('/home/htzanetat...')
#8 {main}
thrown in /home/htzanetatos/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php on line 154