<?php
/**
 * Loop Add to Cart
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/loop/add-to-cart.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://woocommerce.com/document/template-structure/
 * @package     WooCommerce\Templates
 * @version     9.2.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

global $product;
$product_item_layout  = absint( apply_filters( 'multimagazine_product_list_item_layout', 0 ) );
$multimagazine_button_classes = 'add-to-cart product_type_simple add_to_cart_button';

if ( 0 === $product_item_layout ) {
	$multimagazine_button_classes .= ' button';
} elseif ( 0 === strpos( $args['class'], 'button' ) ) {
	$args['class'] = substr( $args['class'], 7 );
}

if ( $product->add_to_cart_url() !== get_permalink( $product->get_id() ) ) {
	$multimagazine_button_classes .= ' ajax_add_to_cart';
}

$multimagazine_url        = $product->add_to_cart_url();
$multimagazine_qty        = isset( $args['quantity'] ) ? $args['quantity'] : 1;
$multimagazine_classes    = isset( $args['class'] ) ? $args['class'] : $multimagazine_button_classes;
$multimagazine_text       = $product->add_to_cart_text();
$multimagazine_product_id = $product->get_id();

?>
<div class="to-cart">
	<a href="<?php echo esc_url( $multimagazine_url ); ?>" data-quantity="<?php echo esc_attr( $multimagazine_qty ); ?>" class="<?php echo esc_attr( $multimagazine_classes ); ?>" data-product_id="<?php echo esc_attr( $multimagazine_product_id ); ?>" rel="nofollow">
		<i class="m-icon m-icon-cart" aria-hidden="true"></i>
		<i class="m-icon m-icon-spinner" aria-hidden="true"></i>
		<i class="m-icon m-icon-check" aria-hidden="true"></i>
		<?php echo esc_html( $multimagazine_text ); ?>
	</a>
</div>
<?php
