add in-app-purchase url params to marketplace suggestions buttons
This commit is contained in:
parent
9652d8f42c
commit
46f2b98bca
|
@ -72,12 +72,12 @@
|
|||
return dismissButton;
|
||||
}
|
||||
|
||||
function addUTMParameters( context, url ) {
|
||||
var utmParams = {
|
||||
utm_source: 'unknown',
|
||||
utm_campaign: 'marketplacesuggestions',
|
||||
utm_medium: 'product'
|
||||
};
|
||||
function addURLParameters( context, url ) {
|
||||
var urlParams = marketplace_suggestions.in_app_purchase_params;
|
||||
urlParams.utm_source = 'unknown';
|
||||
urlParams.utm_campaign = 'marketplacesuggestions';
|
||||
urlParams.utm_medium = 'product';
|
||||
|
||||
var sourceContextMap = {
|
||||
'productstable': [
|
||||
'products-list-inline'
|
||||
|
@ -102,17 +102,17 @@
|
|||
return _.contains( sourceInfo, context );
|
||||
} );
|
||||
if ( utmSource ) {
|
||||
utmParams.utm_source = utmSource;
|
||||
urlParams.utm_source = utmSource;
|
||||
}
|
||||
|
||||
return url + '?' + jQuery.param( utmParams );
|
||||
return url + '?' + jQuery.param( urlParams );
|
||||
}
|
||||
|
||||
// Render DOM element for suggestion linkout, optionally with button style.
|
||||
function renderLinkout( context, product, promoted, slug, url, text, isButton ) {
|
||||
var linkoutButton = document.createElement( 'a' );
|
||||
|
||||
var utmUrl = addUTMParameters( context, url );
|
||||
var utmUrl = addURLParameters( context, url );
|
||||
linkoutButton.setAttribute( 'href', utmUrl );
|
||||
linkoutButton.setAttribute( 'target', 'blank' );
|
||||
linkoutButton.textContent = text;
|
||||
|
|
|
@ -479,6 +479,16 @@ class WC_Admin_Addons {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns in-app-purchase URL params.
|
||||
*/
|
||||
public static function get_in_app_purchase_url_params() {
|
||||
return array(
|
||||
'in-app-purchase-site' => site_url(),
|
||||
'in-app-purchase-woo-version' => WC_VERSION,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add in-app-purchase URL params to link.
|
||||
*
|
||||
|
@ -489,10 +499,7 @@ class WC_Admin_Addons {
|
|||
*/
|
||||
public static function add_in_app_purchase_url_params( $url ) {
|
||||
return add_query_arg(
|
||||
array(
|
||||
'in-app-purchase-site' => site_url(),
|
||||
'in-app-purchase-woo-version' => WC_VERSION,
|
||||
),
|
||||
self::get_in_app_purchase_url_params(),
|
||||
$url
|
||||
);
|
||||
}
|
||||
|
|
|
@ -454,6 +454,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
'dismissed_suggestions' => WC_Marketplace_Suggestions::get_dismissed_suggestions(),
|
||||
'suggestions_data' => WC_Marketplace_Suggestions::get_suggestions_api_data(),
|
||||
'manage_suggestions_url' => admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=woocommerce_com' ),
|
||||
'in_app_purchase_params' => WC_Admin_Addons::get_in_app_purchase_url_params(),
|
||||
'i18n_marketplace_suggestions_default_cta'
|
||||
=> esc_html__( 'Learn More', 'woocommerce' ),
|
||||
'i18n_marketplace_suggestions_dismiss_tooltip'
|
||||
|
|
Loading…
Reference in New Issue