Advertisement
Guest User

Untitled

a guest
Nov 11th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <?php
  2. /**
  3. * Variable product add to cart
  4. *
  5. * @author WooThemes
  6. * @package WooCommerce/Templates
  7. * @version 2.4.0
  8. */
  9. if ( ! defined( 'ABSPATH' ) ) {
  10. exit;
  11. }
  12.  
  13. global $product;
  14.  
  15. $attribute_keys = array_keys( $attributes );
  16.  
  17. do_action( 'woocommerce_before_add_to_cart_form' ); ?>
  18.  
  19. <form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->id ); ?>" data-product_variations="<?php echo esc_attr( json_encode( $available_variations ) ) ?>">
  20. <?php do_action( 'woocommerce_before_variations_form' ); ?>
  21.  
  22. <?php if ( empty( $available_variations ) && false !== $available_variations ) : ?>
  23. <p class="stock out-of-stock"><?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?></p>
  24. <?php else : ?>
  25. <table class="variations" cellspacing="0">
  26. <tbody>
  27. <?php foreach ( $attributes as $attribute_name => $options ) : ?>
  28. <tr>
  29. <td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
  30. <td class="value">
  31. <?php
  32. $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
  33. wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
  34. echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
  35. ?>
  36. </td>
  37. </tr>
  38. <?php endforeach;?>
  39. </tbody>
  40. </table>
  41.  
  42. <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
  43.  
  44. <div class="single_variation_wrap" style="display:none;">
  45. <?php
  46. /**
  47. * woocommerce_before_single_variation Hook
  48. */
  49. do_action( 'woocommerce_before_single_variation' );
  50.  
  51. /**
  52. * woocommerce_single_variation hook. Used to output the cart button and placeholder for variation data.
  53. * @since 2.4.0
  54. * @hooked woocommerce_single_variation - 10 Empty div for variation data.
  55. * @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button.
  56. */
  57. do_action( 'woocommerce_single_variation' );
  58.  
  59. /**
  60. * woocommerce_after_single_variation Hook
  61. */
  62. do_action( 'woocommerce_after_single_variation' );
  63. ?>
  64. </div>
  65.  
  66. <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
  67. <?php endif; ?>
  68.  
  69. <?php do_action( 'woocommerce_after_variations_form' ); ?>
  70. </form>
  71.  
  72. <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement