Skip to content

Commit

Permalink
Improved working on new post
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuesken committed Dec 20, 2024
1 parent af08ad5 commit a431b52
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ document.addEventListener( 'DOMContentLoaded', () => {
};

const checkSubscriptionPeriodsInterval = (period, period_interval, linkBtn) => {
if ( ! linkBtn) {
return;
}
if (
( period === 'year' && parseInt( period_interval ) > 1 ) ||
( period === 'month' && parseInt( period_interval ) > 12 ) ||
Expand All @@ -82,7 +79,7 @@ document.addEventListener( 'DOMContentLoaded', () => {
) {
linkBtn.disabled = true;
linkBtn.checked = false;
linkBtn.setAttribute('title', __( 'Not allowed period intervall combination!', 'woocommerce-paypal-subscriptions' ) );
linkBtn.setAttribute('title', __( 'Not allowed period intervall combination for PayPal Subscriptions!', 'woocommerce-paypal-subscriptions' ) );
} else {
linkBtn.disabled = false;
linkBtn.removeAttribute('title');
Expand Down
43 changes: 28 additions & 15 deletions modules/ppcp-paypal-subscriptions/src/PayPalSubscriptionsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,16 @@ function( $hook ) use ( $c ) {
wp_enqueue_script(
'ppcp-paypal-subscription',
untrailingslashit( $module_url ) . '/assets/js/paypal-subscription.js',
array( 'jquery' ),
array( 'jquery', 'wc-admin-product-editor' ),
$c->get( 'ppcp.asset-version' ),
true
);

wp_set_script_translations(
'ppcp-paypal-subscription',
'woocommerce-paypal-payments'
);

$products = array( $this->set_product_config( $product ) );
if ( $product->get_type() === 'variable-subscription' ) {
$products = array();
Expand Down Expand Up @@ -797,7 +802,7 @@ private function render_paypal_subscription_fields( WC_Product $product, Environ
$subscription_product = $product->get_meta( 'ppcp_subscription_product' );
$subscription_plan = $product->get_meta( 'ppcp_subscription_plan' );
$subscription_plan_name = $product->get_meta( '_ppcp_subscription_plan_name' );
if ( $subscription_product && $subscription_plan ) {
if ( $subscription_product || $subscription_plan ) {
$display_unlink_p = 'display:none;';
if ( $enable_subscription_product !== 'yes' ) {
$display_unlink_p = '';
Expand All @@ -816,23 +821,31 @@ private function render_paypal_subscription_fields( WC_Product $product, Environ
);

$host = $environment->current_environment_is( Environment::SANDBOX ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
echo sprintf(
// translators: %1$s and %2$s are wrapper html tags.
esc_html__( '%1$sProduct%2$s', 'woocommerce-paypal-payments' ),
'<p class="form-field pcpp-product" id="pcpp-product-' . esc_attr( (string) $product->get_id() ) . '"><label style="' . esc_attr( $style ) . '">',
'</label><a href="' . esc_url( $host . '/billing/plans/products/' . $subscription_product['id'] ) . '" target="_blank">' . esc_attr( $subscription_product['id'] ) . '</a></p>'
);
echo sprintf(
// translators: %1$s and %2$s are wrapper html tags.
esc_html__( '%1$sPlan%2$s', 'woocommerce-paypal-payments' ),
'<p class="form-field pcpp-plan" id="pcpp-plan-' . esc_attr( (string) $product->get_id() ) . '"><label style="' . esc_attr( $style ) . '">',
'</label><a href="' . esc_url( $host . '/billing/plans/' . $subscription_plan['id'] ) . '" target="_blank">' . esc_attr( $subscription_plan['id'] ) . '</a></p>'
);
if ( $subscription_product ) {
echo sprintf(
// translators: %1$s and %2$s are wrapper html tags.
esc_html__( '%1$sProduct%2$s', 'woocommerce-paypal-payments' ),
'<p class="form-field pcpp-product" id="pcpp-product-' . esc_attr( (string) $product->get_id() ) . '"><label style="' . esc_attr( $style ) . '">',
'</label><a href="' . esc_url( $host . '/billing/plans/products/' . $subscription_product['id'] ) . '" target="_blank">' . esc_attr( $subscription_product['id'] ) . '</a></p>'
);
}
if ( $subscription_plan ) {
echo sprintf(
// translators: %1$s and %2$s are wrapper html tags.
esc_html__( '%1$sPlan%2$s', 'woocommerce-paypal-payments' ),
'<p class="form-field pcpp-plan" id="pcpp-plan-' . esc_attr( (string) $product->get_id() ) . '"><label style="' . esc_attr( $style ) . '">',
'</label><a href="' . esc_url( $host . '/billing/plans/' . $subscription_plan['id'] ) . '" target="_blank">' . esc_attr( $subscription_plan['id'] ) . '</a></p>'
);
}
} else {
$display_plan_name_p = '';
if ( $enable_subscription_product !== 'yes' && $product->get_name() !== 'AUTO-DRAFT' ) {
$display_plan_name_p = 'display:none;';
}
echo sprintf(
// translators: %1$s and %2$s are wrapper html tags.
esc_html__( '%1$sPlan Name%2$s', 'woocommerce-paypal-payments' ),
'<p class="form-field ppcp_subscription_plan_name_p" id="ppcp_subscription_plan_name_p-' . esc_attr( (string) $product->get_id() ) . '" style="display:none"><label for="_ppcp_subscription_plan_name-' . esc_attr( (string) $product->get_id() ) . '">',
'<p class="form-field ppcp_subscription_plan_name_p" id="ppcp_subscription_plan_name_p-' . esc_attr( (string) $product->get_id() ) . '" style="' . esc_attr( $display_plan_name_p ). '"><label for="_ppcp_subscription_plan_name-' . esc_attr( (string) $product->get_id() ) . '">',
'</label><input type="text" class="short ppcp_subscription_plan_name" id="ppcp_subscription_plan_name-' . esc_attr( (string) $product->get_id() ) . '" name="_ppcp_subscription_plan_name" value="' . esc_attr( $subscription_plan_name ) . '"></p>'
);
}
Expand Down

0 comments on commit a431b52

Please sign in to comment.