Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Created February 12, 2014 01:21
Show Gist options
  • Save EricBusch/8948125 to your computer and use it in GitHub Desktop.
Save EricBusch/8948125 to your computer and use it in GitHub Desktop.
<?php
/**
* Add color attribute.
*
* The attribute "Color" with a slug of "color" must already exist here:
* WordPress Admin Area > Products > Attributes.
*/
add_filter( 'dfrpswc_filter_attribute_value', 'mycode_add_color_attribute', 20, 6 );
function mycode_add_color_attribute( $value, $attribute, $post, $product, $set, $action ) {
if ( $attribute == 'pa_color') {
if ( isset( $product['color'] ) ) {
$value = $product['color'];
}
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment