Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBE Enabling shop onboarding #2871

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion includes/Admin/Settings_Screens/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ function confirmDialog() {
<?php else : ?>

<a href="<?php echo esc_url( facebook_for_woocommerce()->get_connection_handler()->get_connect_url() ); ?>" class="button button-primary">
<?php esc_html_e( 'Get Started', 'facebook-for-woocommerce' ); ?>
<?php esc_html_e( 'Get Started with Ads', 'facebook-for-woocommerce' ); ?>
</a>

<a href="<?php echo esc_url( facebook_for_woocommerce()->get_connection_handler()->get_connect_url(true) ); ?>" class="button button-primary">
<?php esc_html_e( 'Get Started with Shop and Ads', 'facebook-for-woocommerce' ); ?>
</a>

<?php endif; ?>
Expand Down
21 changes: 11 additions & 10 deletions includes/Handlers/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,6 @@ public function handle_connect() {
}
update_option( 'wc_facebook_has_connected_fbe_2', 'yes' );
update_option( 'wc_facebook_has_authorized_pages_read_engagement', 'yes' );
// redirect to the Commerce onboarding if directed to do so
if ( ! empty( Helper::get_requested_value( 'connect_commerce' ) ) ) {
wp_safe_redirect( $this->get_commerce_connect_url() );
exit;
}
facebook_for_woocommerce()->get_message_handler()->add_message( __( 'Connection successful!', 'facebook-for-woocommerce' ) );
wp_safe_redirect( facebook_for_woocommerce()->get_advertise_tab_url() );
exit;
Expand Down Expand Up @@ -888,9 +883,6 @@ public function get_redirect_url() {
*/
public function get_connect_parameters( $connect_commerce = false ) {
$state = $this->get_redirect_url();
if ( $connect_commerce ) {
$state = add_query_arg( 'connect_commerce', true, $state );
}

/**
* Filters the connection parameters.
Expand All @@ -909,7 +901,7 @@ public function get_connect_parameters( $connect_commerce = false ) {
'display' => 'page',
'response_type' => 'code',
'scope' => implode( ',', $this->get_scopes() ),
'extras' => json_encode( $this->get_connect_parameters_extras() ),
'extras' => json_encode( $this->get_connect_parameters_extras( $connect_commerce ) ),
)
);
}
Expand All @@ -924,7 +916,7 @@ public function get_connect_parameters( $connect_commerce = false ) {
*
* @return array associative array (to be converted to JSON encoded for connection purposes)
*/
private function get_connect_parameters_extras() {
private function get_connect_parameters_extras( $connect_commerce = false ) {
$parameters = array(
'setup' => array(
'external_business_id' => $this->get_external_business_id(),
Expand All @@ -944,6 +936,15 @@ private function get_connect_parameters_extras() {
if ( $external_merchant_settings_id = facebook_for_woocommerce()->get_integration()->get_external_merchant_settings_id() ) {
$parameters['setup']['merchant_settings_id'] = $external_merchant_settings_id;
}

if ($connect_commerce) {
$parameters['setup']['channel'] = 'COMMERCE';
$parameters['setup']['external_client_metadata'] = [
'commerce_partner_seller_platform_type' => 'UNKNOWN',
'feature_set_eligibility' => 'SHOP_FIRST',
];
}

return $parameters;
}

Expand Down