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;
|
return dismissButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addUTMParameters( context, url ) {
|
function addURLParameters( context, url ) {
|
||||||
var utmParams = {
|
var urlParams = marketplace_suggestions.in_app_purchase_params;
|
||||||
utm_source: 'unknown',
|
urlParams.utm_source = 'unknown';
|
||||||
utm_campaign: 'marketplacesuggestions',
|
urlParams.utm_campaign = 'marketplacesuggestions';
|
||||||
utm_medium: 'product'
|
urlParams.utm_medium = 'product';
|
||||||
};
|
|
||||||
var sourceContextMap = {
|
var sourceContextMap = {
|
||||||
'productstable': [
|
'productstable': [
|
||||||
'products-list-inline'
|
'products-list-inline'
|
||||||
|
@ -102,17 +102,17 @@
|
||||||
return _.contains( sourceInfo, context );
|
return _.contains( sourceInfo, context );
|
||||||
} );
|
} );
|
||||||
if ( utmSource ) {
|
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.
|
// Render DOM element for suggestion linkout, optionally with button style.
|
||||||
function renderLinkout( context, product, promoted, slug, url, text, isButton ) {
|
function renderLinkout( context, product, promoted, slug, url, text, isButton ) {
|
||||||
var linkoutButton = document.createElement( 'a' );
|
var linkoutButton = document.createElement( 'a' );
|
||||||
|
|
||||||
var utmUrl = addUTMParameters( context, url );
|
var utmUrl = addURLParameters( context, url );
|
||||||
linkoutButton.setAttribute( 'href', utmUrl );
|
linkoutButton.setAttribute( 'href', utmUrl );
|
||||||
linkoutButton.setAttribute( 'target', 'blank' );
|
linkoutButton.setAttribute( 'target', 'blank' );
|
||||||
linkoutButton.textContent = text;
|
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.
|
* 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 ) {
|
public static function add_in_app_purchase_url_params( $url ) {
|
||||||
return add_query_arg(
|
return add_query_arg(
|
||||||
array(
|
self::get_in_app_purchase_url_params(),
|
||||||
'in-app-purchase-site' => site_url(),
|
|
||||||
'in-app-purchase-woo-version' => WC_VERSION,
|
|
||||||
),
|
|
||||||
$url
|
$url
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,6 +454,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
||||||
'dismissed_suggestions' => WC_Marketplace_Suggestions::get_dismissed_suggestions(),
|
'dismissed_suggestions' => WC_Marketplace_Suggestions::get_dismissed_suggestions(),
|
||||||
'suggestions_data' => WC_Marketplace_Suggestions::get_suggestions_api_data(),
|
'suggestions_data' => WC_Marketplace_Suggestions::get_suggestions_api_data(),
|
||||||
'manage_suggestions_url' => admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=woocommerce_com' ),
|
'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'
|
'i18n_marketplace_suggestions_default_cta'
|
||||||
=> esc_html__( 'Learn More', 'woocommerce' ),
|
=> esc_html__( 'Learn More', 'woocommerce' ),
|
||||||
'i18n_marketplace_suggestions_dismiss_tooltip'
|
'i18n_marketplace_suggestions_dismiss_tooltip'
|
||||||
|
|
Loading…
Reference in New Issue