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

fix: alpha fixes #2835

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,19 @@ public static function render_billing_template() {
* Add the necessary endpoints to rewrite rules.
*/
public static function add_rewrite_endpoints() {
$has_set_up_custom_billing_endpoint = \get_option( '_newspack_has_set_up_custom_billing_endpoint' );
if ( ! Donations::is_platform_stripe() ) {
if ( $has_set_up_custom_billing_endpoint ) {
\delete_option( '_newspack_has_set_up_custom_billing_endpoint' );
\flush_rewrite_rules(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
Logger::log( 'Flushed rewrite rules to remove Stripe billing endpoint' );
}
return;
}
\add_rewrite_endpoint( self::BILLING_ENDPOINT, EP_PAGES );
if ( ! \get_option( '_newspack_has_set_up_custom_billing_endpoint' ) ) {
if ( ! $has_set_up_custom_billing_endpoint ) {
\flush_rewrite_rules(); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
Logger::log( 'Flushed rewrite rules to add billing endpoint' );
Logger::log( 'Flushed rewrite rules to add Stripe billing endpoint' );
\update_option( '_newspack_has_set_up_custom_billing_endpoint', true );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ public static function add_checkout_fields( $fields ) {
*
* @param string $posted_data Posted posted_data.
*/
public static function set_total_with_fees( $order, $data ) {
if ( isset( $data[ self::CUSTOM_FIELD_NAME ] ) && 1 === $data[ self::CUSTOM_FIELD_NAME ] ) {
$order->add_meta_data( self::WC_ORDER_META_NAME, 1 );
$order->set_total( self::get_total_with_fee( $order->get_total() ) );
$order->save();
public static function persist_fee_selection( $posted_data ) {
$data = [];
parse_str( $posted_data, $data );
if ( self::should_apply_fee( $data ) ) {
\WC()->session->set( self::CUSTOM_FIELD_NAME, 1 );
} else {
\WC()->session->set( self::CUSTOM_FIELD_NAME, 0 );
}
}

Expand Down