Пример #1
0
function yiw_add_to_cart_success_ajax($datas)
{
    global $woocommerce;
    // quantity
    $qty = 0;
    if (sizeof($woocommerce->cart->get_cart()) > 0) {
        foreach ($woocommerce->cart->get_cart() as $item_id => $values) {
            $qty += $values['quantity'];
        }
    }
    if ($qty == 1) {
        $label = __('item', 'yiw');
    } else {
        $label = __('items', 'yiw');
    }
    ob_start();
    echo '<ul class="cart_list product_list_widget hide_cart_widget_if_empty">';
    if (sizeof($woocommerce->cart->get_cart()) > 0) {
        foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) {
            $_product = $cart_item['data'];
            if ($_product->exists() && $cart_item['quantity'] > 0) {
                echo '<li><a href="' . get_permalink($cart_item['product_id']) . '">';
                echo $_product->get_image();
                echo apply_filters('woocommerce_cart_widget_product_title', $_product->get_title(), $_product) . '</a>';
                echo $woocommerce->cart->get_item_data($cart_item);
                echo '<span class="quantity">' . $cart_item['quantity'] . ' &times; ' . apply_filters('woocommerce_cart_item_price_html', woocommerce_price($_product->price), $values, $cart_item_key) . '</span></li>';
            }
        }
    } else {
        echo '<li class="empty">' . __('No products in the cart.', 'yiw') . '</li>';
    }
    echo '</ul>';
    if ($qty == 1) {
        echo '<p class="total"><strong>' . __('Subtotal', 'yiw') . ':</strong> ' . $woocommerce->cart->get_cart_total() . '</p>';
        do_action('woocommerce_widget_shopping_cart_before_buttons');
        echo '<p class="buttons"><a href="' . $woocommerce->cart->get_cart_url() . '" class="button">' . __('View Cart &rarr;', 'yiw') . '</a> <a href="' . $woocommerce->cart->get_checkout_url() . '" class="button checkout">' . __('Checkout &rarr;', 'yiw') . '</a></p>';
    }
    $widget = ob_get_clean();
    //$datas['span.minicart'] = '<span class="minicart">' . $qty . ' ' . $label . '</span>';
    $datas['.quick-cart .widget_shopping_cart .cart_list'] = $widget;
    $datas['.widget_shopping_cart .total .amount'] = $woocommerce->cart->get_cart_total();
    $datas['#cart'] = '<div id="cart">' . yiw_minicart(false) . '</div>';
    return $datas;
}
Пример #2
0
                        <?php 
    }
}
if (!$yiw_is_woocommerce and !yiw_get_option('topbar_login') and !yiw_get_option('topbar_register')) {
    echo ' | ';
}
if (!$yiw_is_woocommerce && !yiw_get_option('topbar_register')) {
    echo '<li>';
    wp_register('', '');
    echo '</li>';
}
?>

                    </ul>
                </div>
				<?php 
if ($show_ribbon) {
    ?>

                <div id="cart">
					<?php 
    yiw_minicart();
    ?>

				</div><!-- #cart -->
				<?php 
}
?>

			</div><!-- .inner -->
		</div><!-- #top -->