mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Improved working on new post
This commit is contained in:
parent
af08ad5fce
commit
a431b52094
2 changed files with 29 additions and 19 deletions
|
@ -71,9 +71,6 @@ document.addEventListener( 'DOMContentLoaded', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkSubscriptionPeriodsInterval = (period, period_interval, linkBtn) => {
|
const checkSubscriptionPeriodsInterval = (period, period_interval, linkBtn) => {
|
||||||
if ( ! linkBtn) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
( period === 'year' && parseInt( period_interval ) > 1 ) ||
|
( period === 'year' && parseInt( period_interval ) > 1 ) ||
|
||||||
( period === 'month' && parseInt( period_interval ) > 12 ) ||
|
( period === 'month' && parseInt( period_interval ) > 12 ) ||
|
||||||
|
@ -82,7 +79,7 @@ document.addEventListener( 'DOMContentLoaded', () => {
|
||||||
) {
|
) {
|
||||||
linkBtn.disabled = true;
|
linkBtn.disabled = true;
|
||||||
linkBtn.checked = false;
|
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 {
|
} else {
|
||||||
linkBtn.disabled = false;
|
linkBtn.disabled = false;
|
||||||
linkBtn.removeAttribute('title');
|
linkBtn.removeAttribute('title');
|
||||||
|
|
|
@ -562,11 +562,16 @@ class PayPalSubscriptionsModule implements ServiceModule, ExtendingModule, Execu
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'ppcp-paypal-subscription',
|
'ppcp-paypal-subscription',
|
||||||
untrailingslashit( $module_url ) . '/assets/js/paypal-subscription.js',
|
untrailingslashit( $module_url ) . '/assets/js/paypal-subscription.js',
|
||||||
array( 'jquery' ),
|
array( 'jquery', 'wc-admin-product-editor' ),
|
||||||
$c->get( 'ppcp.asset-version' ),
|
$c->get( 'ppcp.asset-version' ),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
wp_set_script_translations(
|
||||||
|
'ppcp-paypal-subscription',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
);
|
||||||
|
|
||||||
$products = array( $this->set_product_config( $product ) );
|
$products = array( $this->set_product_config( $product ) );
|
||||||
if ( $product->get_type() === 'variable-subscription' ) {
|
if ( $product->get_type() === 'variable-subscription' ) {
|
||||||
$products = array();
|
$products = array();
|
||||||
|
@ -797,7 +802,7 @@ class PayPalSubscriptionsModule implements ServiceModule, ExtendingModule, Execu
|
||||||
$subscription_product = $product->get_meta( 'ppcp_subscription_product' );
|
$subscription_product = $product->get_meta( 'ppcp_subscription_product' );
|
||||||
$subscription_plan = $product->get_meta( 'ppcp_subscription_plan' );
|
$subscription_plan = $product->get_meta( 'ppcp_subscription_plan' );
|
||||||
$subscription_plan_name = $product->get_meta( '_ppcp_subscription_plan_name' );
|
$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;';
|
$display_unlink_p = 'display:none;';
|
||||||
if ( $enable_subscription_product !== 'yes' ) {
|
if ( $enable_subscription_product !== 'yes' ) {
|
||||||
$display_unlink_p = '';
|
$display_unlink_p = '';
|
||||||
|
@ -816,23 +821,31 @@ class PayPalSubscriptionsModule implements ServiceModule, ExtendingModule, Execu
|
||||||
);
|
);
|
||||||
|
|
||||||
$host = $environment->current_environment_is( Environment::SANDBOX ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
|
$host = $environment->current_environment_is( Environment::SANDBOX ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
|
||||||
echo sprintf(
|
if ( $subscription_product ) {
|
||||||
// translators: %1$s and %2$s are wrapper html tags.
|
echo sprintf(
|
||||||
esc_html__( '%1$sProduct%2$s', 'woocommerce-paypal-payments' ),
|
// translators: %1$s and %2$s are wrapper html tags.
|
||||||
'<p class="form-field pcpp-product" id="pcpp-product-' . esc_attr( (string) $product->get_id() ) . '"><label style="' . esc_attr( $style ) . '">',
|
esc_html__( '%1$sProduct%2$s', 'woocommerce-paypal-payments' ),
|
||||||
'</label><a href="' . esc_url( $host . '/billing/plans/products/' . $subscription_product['id'] ) . '" target="_blank">' . esc_attr( $subscription_product['id'] ) . '</a></p>'
|
'<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' ),
|
if ( $subscription_plan ) {
|
||||||
'<p class="form-field pcpp-plan" id="pcpp-plan-' . esc_attr( (string) $product->get_id() ) . '"><label style="' . esc_attr( $style ) . '">',
|
echo sprintf(
|
||||||
'</label><a href="' . esc_url( $host . '/billing/plans/' . $subscription_plan['id'] ) . '" target="_blank">' . esc_attr( $subscription_plan['id'] ) . '</a></p>'
|
// 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 {
|
} else {
|
||||||
|
$display_plan_name_p = '';
|
||||||
|
if ( $enable_subscription_product !== 'yes' && $product->get_name() !== 'AUTO-DRAFT' ) {
|
||||||
|
$display_plan_name_p = 'display:none;';
|
||||||
|
}
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
// translators: %1$s and %2$s are wrapper html tags.
|
// translators: %1$s and %2$s are wrapper html tags.
|
||||||
esc_html__( '%1$sPlan Name%2$s', 'woocommerce-paypal-payments' ),
|
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>'
|
'</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>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue