Skip to content

Commit

Permalink
Make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
artpi committed Mar 27, 2019
1 parent bd2284d commit a72a7c4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
5 changes: 3 additions & 2 deletions _inc/lib/core-api/wpcom-endpoints/memberships.php
Expand Up @@ -79,7 +79,7 @@ public function create_product( $request ) {
$blog_id = Jetpack_Options::get_option( 'id' );
$response = Jetpack_Client::wpcom_json_api_request_as_blog(
"/sites/$blog_id/{$this->rest_base}/product",
'v2',
'2',
array(
'method' => 'POST',
),
Expand All @@ -88,7 +88,8 @@ public function create_product( $request ) {
'price' => $request['price'],
'currency' => $request['currency'],
'interval' => $request['interval'],
)
),
'wpcom'
);
if ( is_wp_error( $response ) ) {
return new WP_Error( 'wpcom_connection_error', 'Could not connect to WP.com', 404 );
Expand Down
32 changes: 16 additions & 16 deletions extensions/blocks/membership-button/edit.jsx
Expand Up @@ -63,16 +63,12 @@ class MembershipsButtonEdit extends Component {
const fetch = { path, method };
apiFetch( fetch ).then(
result => {
this.setState( {
products: this.state.products.concat( [
{
id: result.id,
title: result.title,
interval: result.interval,
price: result.price,
},
] ),
} );
const connectURL = result.connect_url;
const products = result.products;
const connected = result.connected_account_id
? API_STATE_CONNECTED
: API_STATE_NOTCONNECTED;
this.setState( { connected, connectURL, products } );
}
// result => {
// const connectURL = null;
Expand Down Expand Up @@ -117,12 +113,16 @@ class MembershipsButtonEdit extends Component {
const fetch = { path, method, data };
apiFetch( fetch ).then(
result => {
const connectURL = result.connect_url;
const products = result.products;
const connected = result.connected_account_id
? API_STATE_CONNECTED
: API_STATE_NOTCONNECTED;
this.setState( { connected, connectURL, products } );
this.setState( {
products: this.state.products.concat( [
{
id: result.id,
title: result.title,
interval: result.interval,
price: result.price,
},
] ),
} );
}
// result => {
// const connectURL = null;
Expand Down
4 changes: 2 additions & 2 deletions modules/memberships/class-jetpack-memberships.php
Expand Up @@ -17,7 +17,7 @@ class Jetpack_Memberships {
*
* @var string
*/
static private $css_classname_prefix = 'jetpack-memberships';
static public $css_classname_prefix = 'jetpack-memberships';
/**
* Increase this number each time there's a change in CSS or JS to bust cache.
*
Expand Down Expand Up @@ -245,7 +245,7 @@ public function render_button( $attrs ) {
$button_styles,
sprintf(
'color: %s',
sanitize_hex_color( $attr['customTextButtonColor'] )
sanitize_hex_color( $attrs['customTextButtonColor'] )
)
);
}
Expand Down

0 comments on commit a72a7c4

Please sign in to comment.