BackwardsCompatibility.class.php
4 years ago
Blocks.class.php
4 years ago
CustomPostTypes.class.php
4 years ago
Dashboard.class.php
4 years ago
DeactivationSurvey.class.php
4 years ago
InstallationWalkthrough.class.php
4 years ago
Permissions.class.php
4 years ago
ReviewAsk.class.php
4 years ago
Settings.class.php
4 years ago
Widgets.class.php
4 years ago
WooCommerceIntegration.class.php
4 years ago
template-functions.php
4 years ago
WooCommerceIntegration.class.php
51 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class to replace the main WooCommerce product image with a slider |
| 5 | * that contains all of the product images |
| 6 | */ |
| 7 | |
| 8 | if ( !defined( 'ABSPATH' ) ) |
| 9 | exit; |
| 10 | |
| 11 | class ewdusWooCommerceIntegration { |
| 12 | |
| 13 | |
| 14 | public function __construct() { |
| 15 | |
| 16 | add_filter( 'woocommerce_single_product_image_thumbnail_html', array( $this, 'remove_wc_thumbnails' ) ); |
| 17 | add_filter( 'woocommerce_single_product_image_html', array( $this, 'replace_woocommerce_image' ), 10, 2 ); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Replace main WooCommerce image with a slider containing all product images |
| 22 | * @since 2.0.0 |
| 23 | */ |
| 24 | public function replace_woocommerce_image( $html, $product_id ) { |
| 25 | |
| 26 | $product = wc_get_product( $product_id ); |
| 27 | |
| 28 | $post_ids = get_post_thumbnail_id( $product_id ); |
| 29 | $attachment_ids = $product->get_gallery_attachment_ids(); |
| 30 | |
| 31 | if ( $attachment_ids ) { |
| 32 | |
| 33 | foreach ( $attachment_ids as $attachment_id ) { |
| 34 | $post_ids .= "," . $attachment_id; |
| 35 | } |
| 36 | |
| 37 | return do_shortcode( '[ultimate-slider post__in_string="' . $post_ids . '"]' ); |
| 38 | } |
| 39 | |
| 40 | return $html; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Remove the product image thumbnails if displaying the slider |
| 45 | * @since 2.0.0 |
| 46 | */ |
| 47 | public function remove_wc_thumbnails() { |
| 48 | |
| 49 | return null; |
| 50 | } |
| 51 | } |