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 | |
| /** | |
| * Display the Savings discount for a product that's on sale on product list pages. | |
| */ | |
| add_action( 'woocommerce_after_shop_loop_item', 'mycode_show_discount_in_product_lists' ); | |
| function mycode_show_discount_in_product_lists() { | |
| global $product; | |
| $salediscount = get_post_meta( $product->id, '_dfrps_salediscount', true ); | |
| if ( $salediscount > 0 ) { |
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 | |
| /** | |
| * Add merchant logo (if exists) to product details page. | |
| */ | |
| add_action( 'woocommerce_external_add_to_cart', 'mycode_add_merchant_logo' ); | |
| function mycode_add_merchant_logo() { | |
| global $product; | |
| if ( dfrpswc_is_dfrpswc_product( $product->id ) ) { | |
| $postmeta = get_post_meta( $product->id, '_dfrps_product', true ); |
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 | |
| /** | |
| * Remove "SKU" from product details page. | |
| */ | |
| add_filter( 'wc_product_sku_enabled', 'mycode_remove_sku_from_product_page' ); | |
| function mycode_remove_sku_from_product_page( $boolean ) { | |
| if ( is_single() ) { | |
| $boolean = false; | |
| } |
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 | |
| /** | |
| * 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 ) { |
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 | |
| /** | |
| * Add gender attribute. | |
| * | |
| * The attribute "Gender" must already exist here: | |
| * WordPress Admin Area > Products > Attributes. | |
| */ | |
| add_filter( 'dfrpswc_filter_attribute_value', 'mycode_add_gender_attribute', 20, 6 ); | |
| function mycode_add_gender_attribute( $value, $attribute, $post, $product, $set, $action ) { |
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 | |
| /** | |
| * Add size attribute. | |
| * | |
| * The attribute "Size" with a slug of "size" must already exist here: | |
| * WordPress Admin Area > Products > Attributes. | |
| */ | |
| add_filter( 'dfrpswc_filter_attribute_value', 'mycode_add_size_attribute', 20, 6 ); | |
| function mycode_add_size_attribute( $value, $attribute, $post, $product, $set, $action ) { |
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 | |
| /** | |
| * Add the custom attribute "Special Promotion" to a product. | |
| */ | |
| add_filter( 'dfrpswc_product_attributes', 'mycode_add_promo_attribute', 20, 5 ); | |
| function mycode_add_promo_attribute( $attributes, $post, $product, $set, $action ) { | |
| if ( isset( $product['promo'] ) ) { | |
| $attr = 'Special Promotion'; | |
| if ( !isset( $attributes[sanitize_title( $attr )] ) ) { |
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 | |
| $search = $api->merchantSearchRequest(); | |
| $search->addFilter( 'name LIKE pets' ); // where 'pets' is in merchant name. | |
| $search->addFilter( 'product_count > 0' ); // where product count is greater than 0. | |
| $search->addFilter( 'source_id IN 3,7' ); // where network ID is 3 or 7. | |
| $search->addSort( 'product_count' ); // sort by product count ascending. | |
| $merchants = $search->execute(); | |
| $networks = $search->getNetworks(); |
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 | |
| $search = $api->searchRequest(); | |
| $search->addFilter('ANY LIKE shoes'); | |
| $search->addSort('+finalprice'); | |
| $products = $search->execute(); |
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
| /** | |
| * Convert ampersands. | |
| * | |
| * Changes "&" to "&". | |
| */ | |
| add_filter( 'wccal_filter_url', 'wporg_6700183_handle_ampersands', 20, 2 ); | |
| function wporg_6700183_handle_ampersands( $external_link, $post_id ) { | |
| $external_link = str_replace( "&", "&", $external_link ); | |
| return $external_link; | |
| } |