Last active
October 31, 2017 13:16
-
-
Save EricBusch/7baac5a60ca64d75ff5ea962ef04344e to your computer and use it in GitHub Desktop.
Custom function that returns the affiliate URL with inserted affiliate ID for any Datafeedr product imported by the Product Sets plugin and saved as a WooCommerce External Product. [datafeedr]
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 | |
/** | |
* Returns the affiliate URL with inserted affiliate ID for any | |
* Datafeedr product imported by the Product Sets plugin and | |
* saved as a WooCommerce Product. | |
* | |
* Usage: $url = mycode_dfrapi_url( $product ); | |
* | |
* Returns an empty string if no Datafeedr product exists. | |
* | |
* @param WC_Product $product | |
* | |
* @return string URL or empty string. | |
*/ | |
function mycode_dfrapi_url( WC_Product $product ) { | |
$dfrps_product = get_post_meta( $product->get_id(), '_dfrps_product', true ); | |
if ( empty( $dfrps_product ) ) { | |
return ''; | |
} | |
$url = dfrapi_url( $dfrps_product ); | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment