Skip to content

Instantly share code, notes, and snippets.

@scottopolis
Created March 1, 2021 19:01
Show Gist options
  • Save scottopolis/8152fd047bc4bcb93cb8f6b8c8c1d19a to your computer and use it in GitHub Desktop.
Save scottopolis/8152fd047bc4bcb93cb8f6b8c8c1d19a to your computer and use it in GitHub Desktop.
AppCommerce Attribute Swatches
<?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