/** * Widget * Display the widget in the sidebar * Save output to the cache if empty * * @param array sidebar arguments * @param array instance */ public function widget($args, $instance) { // Hide widget if page is the cart or checkout if (is_cart() || is_checkout()) { return false; } extract($args); // Set the widget title $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Cart', 'fflcommerce'), $instance, $this->id_base); // Print the widget wrapper & title echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } // Get the contents of the cart $cart_contents = fflcommerce_cart::$cart_contents; // If there are items in the cart print out a list of products if (!empty($cart_contents)) { // Open the list echo '<ul class="cart_list">'; foreach ($cart_contents as $key => $value) { // Get product instance $_product = $value['data']; if ($_product->exists() && $value['quantity'] > 0) { echo '<li>'; // Print the product image & title with a link to the permalink echo '<a href="' . esc_attr(get_permalink($_product->id)) . '" title="' . esc_attr($_product->get_title()) . '">'; // Print the product thumbnail image if exists else display placeholder echo has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : fflcommerce_get_image_placeholder('shop_tiny'); // Print the product title echo '<span class="js_widget_product_title">' . $_product->get_title() . '</span>'; echo '</a>'; // Displays variations and cart item meta echo fflcommerce_cart::get_item_data($value); // Print the quantity & price per product echo '<span class="js_widget_product_price">' . $value['quantity'] . ' × ' . $_product->get_price_html() . '</span>'; echo '</li>'; } } echo '</ul>'; // Close the list // Print the cart total echo '<p class="total"><strong>'; echo __('Subtotal', 'fflcommerce'); echo ':</strong> ' . fflcommerce_price($this->total_cart_items()); echo '</p>'; do_action('fflcommerce_widget_cart_before_buttons'); // Print view cart & checkout buttons $view_cart_button_label = isset($instance['view_cart_button']) ? $instance['view_cart_button'] : __('View Cart →', 'fflcommerce'); $checkout_button_label = isset($instance['checkout_button']) ? $instance['checkout_button'] : __('Checkout →', 'fflcommerce'); echo '<p class="buttons">'; echo '<a href="' . esc_attr(fflcommerce_cart::get_cart_url()) . '" class="button">' . __($view_cart_button_label, 'fflcommerce') . '</a>'; echo '<a href="' . esc_attr(fflcommerce_cart::get_checkout_url()) . '" class="button checkout">' . __($checkout_button_label, 'fflcommerce') . '</a>'; echo '</p>'; } else { echo '<span class="empty">' . __('No products in the cart.', 'fflcommerce') . '</span>'; } // Print closing widget wrapper echo $after_widget; }
?> </th> </tr> <?php do_action('fflcommerce_shop_table_cart_head'); ?> </thead> <tbody> <?php foreach ($cart as $cart_item_key => $values) { ?> <?php /** @var fflcommerce_product $product */ $product = $values['data']; if ($product->exists() && $values['quantity'] > 0) { $additional_description = fflcommerce_cart::get_item_data($values); ?> <tr data-item="<?php echo $cart_item_key; ?> " data-product="<?php echo $product->id; ?> "> <td class="product-remove"> <a href="<?php echo esc_url(fflcommerce_cart::get_remove_url($cart_item_key)); ?> " class="remove" title="<?php echo esc_attr(__('Remove this item.', 'fflcommerce')); ?>
_e('Grand Total', 'fflcommerce'); ?> </strong></td> <td><strong><?php echo fflcommerce_cart::get_total(); ?> </strong></td> </tr> </tfoot> <tbody> <?php foreach (fflcommerce_cart::$cart_contents as $item_id => $values) { /** @var fflcommerce_product $product */ $product = $values['data']; if ($product->exists() && $values['quantity'] > 0) { $variation = fflcommerce_cart::get_item_data($values); $customization = ''; $custom_products = (array) fflcommerce_session::instance()->customized_products; $product_id = !empty($values['variation_id']) ? $values['variation_id'] : $values['product_id']; $custom = isset($custom_products[$product_id]) ? $custom_products[$product_id] : ''; ?> <tr> <td class="product-name"> <?php echo $product->get_title() . $variation; if (!empty($custom)) { $label = apply_filters('fflcommerce_customized_product_label', __(' Personal: ', 'fflcommerce')); ?> <dl class="customization"> <dt class="customized_product_label"> <?php