PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
← All changes | includes/core/rest-api/Controllers/class-orderbump-controller.php +59 -5 2.8.16 → 3.13.3 View file →
@@ -402,11 +402,9 @@
402 402 *
403 403 * @return mixed
404 404 * @throws \Exception
405 405 */
406 - public function get_setting(WP_REST_Request $request)
407 - {
408 -
406 + public function get_setting(WP_REST_Request $request){
409 407 $step_id = $request['step_id'];
410 408 $all_settings = get_post_meta($step_id, 'order-bump-settings', true) ? get_post_meta($step_id, 'order-bump-settings', true) : array();
411 409 $is_multiple = Wpfnl_functions::check_array_is_multidimentional( $all_settings );
412 410
@@ -437,14 +435,54 @@
437 435 }
438 436 if( !isset($settings['obDescriptionColor']) || !$settings['obDescriptionColor'] ){
439 437 $all_settings[$key]['obDescriptionColor'] = '#7A8B9A';
440 438 }
439 + if(!isset($settings['obChooseVariantColor']) ||!$settings['obChooseVariantColor'] ){
440 + $all_settings[$key]['obChooseVariantColor'] = '#F34D01';
441 + }
442 + if(!isset($settings['chooseVariantName']) ||!$settings['chooseVariantName'] ){
443 + $all_settings[$key]['chooseVariantName'] = 'Choose an Option';
444 + }
445 +
446 + if( !isset($settings['replaceSettings']) || !$settings['replaceSettings'] ){
447 + $all_settings[$key]['replaceSettings'] = [
448 + 'isAllReplace' => 'yes',
449 + 'selectedProducts' => [],
450 + ];
451 + }
452 +
453 + if( !isset($settings['prePurchaseUpsell']) || !$settings['prePurchaseUpsell'] ){
454 + $all_settings[$key]['prePurchaseUpsell'] = 'no';
455 + }
456 +
457 + if( !empty($settings['product']) ){
458 + $product = wc_get_product($settings['product']);
459 + if( $product ){
460 + $sale_price = 0;
461 + $regular_price = 0;
462 +
463 + // For variable products, get prices from variation range
464 + if( $product->is_type('variable') ){
465 + $sale_price = $product->get_variation_sale_price('min');
466 + $regular_price = $product->get_variation_regular_price('min');
467 + } else {
468 + $sale_price = $product->get_sale_price();
469 + $regular_price = $product->get_regular_price();
470 + }
471 +
472 + $all_settings[$key]['numericSalePrice'] = wc_price(floatval($sale_price) * intval($settings['quantity']));
473 + $all_settings[$key]['numericRegularPrice'] = wc_price(floatval($regular_price) * intval($settings['quantity']));
474 + }
475 + }
441 476 }
442 -
477 + // Add global funnel status to response
478 + $funnel_id = get_post_meta($step_id, '_funnel_id', true);
479 + $is_global_funnel = get_post_meta($funnel_id, 'is_global_funnel', true);
480 +
443 481 $response['success'] = true;
444 482 $response['data'] = $all_settings;
483 + $response['isEnableGbf'] = $is_global_funnel === 'yes' ? true : false;
445 484 $response['ob_position'] = $step_id ? Wpfnl_functions::supported_orderbump_position( $step_id ) : [];
446 -
447 485 return rest_ensure_response($response);
448 486
449 487 }
450 488
@@ -473,8 +511,22 @@
473 511 $class_object = Wpfnl_Controller_Type_Factory::build($type);
474 512 if( $class_object ){
475 513 $all_settings = $class_object->update_ob_settings( $all_settings );
476 514 }
515 +
516 + // Validate quantity in all order bump settings
517 + if (is_array($all_settings)) {
518 + foreach ($all_settings as $key => $settings) {
519 + if (isset($settings['quantity'])) {
520 + $quantity = absint($settings['quantity']);
521 + if ($quantity < 1) {
522 + $quantity = 1;
523 + }
524 + $all_settings[$key]['quantity'] = $quantity;
525 + }
526 + }
527 + }
528 +
477 529 $response = array();
478 530 $step_id = $all_settings_value['stepID'];
479 531 update_post_meta($step_id, 'order-bump-settings', $all_settings);
480 532 // update_post_meta($step_id, 'order-bump', $settings['isEnabled']);
@@ -479,8 +531,10 @@
479 531 update_post_meta($step_id, 'order-bump-settings', $all_settings);
480 532 // update_post_meta($step_id, 'order-bump', $settings['isEnabled']);
481 533 do_action( 'wpfunnels/after_save_order_bump_data', $step_id, $all_settings );
482 534 $response['success'] = true;
535 +
536 + do_action( 'wpfunnels_order_bump_added', absint( $funnel_id ), absint( $step_id ) );
483 537
484 538 }
485 539
486 540