Created
March 1, 2021 19:01
-
-
Save scottopolis/8152fd047bc4bcb93cb8f6b8c8c1d19a to your computer and use it in GitHub Desktop.
AppCommerce Attribute Swatches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Support Variation Swatches for WooCommerce plugin in AppPresser | |
// put this code in a custom plugin | |
add_filter( 'appcommerce_attribute_terms', function( $terms ) { | |
foreach( $terms as $key => $option) : | |
// if you have a different plugin, just replace 'product_attribute_color' with the key from your plugin | |
$terms[$key]->attribute_color = get_term_meta( $option->term_id, 'product_attribute_color', 1 ); | |
$terms[$key]->attribute_image = wp_get_attachment_url( get_term_meta( $option->term_id, 'product_attribute_image', 1 ) ); | |
endforeach; | |
return $terms; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment