How to overwrite woocommerce_checkout_must_be_logged_in_message when germanized pro and sumosubscriptions are active?

i have the following bug:when buying a product that is managed by sumosubscriptions in my woocommerce store, and when email is assigned to a user, but user is not logged in, where is error-message Für diese E-Mail-Adresse existiert bereits ein Account. Bitte logge dich ein -> but without link.

I tried adding this to functions.php:

add_filter( 'woocommerce_checkout_posted_data', 'ftm_filter_checkout_posted_data', 10, 1 );
function ftm_filter_checkout_posted_data( $data ) {
 
    $email = $data['billing_email'];
 
    if ( email_exists( $email ) ) $data['createaccount'] = 0;
 
    return $data;
 
}

but deactivating the error wouldnt work.

then i tried adding a link with that filter:

function filter_woocommerce_checkout_must_be_logged_in_message( $message ) {
    $message = 'You must be logged in to checkout. <a href="#" id="login-register">login / Register</a>';
    return $message; 
}
add_filter( 'woocommerce_checkout_must_be_logged_in_message', 'filter_woocommerce_checkout_must_be_logged_in_message', 10, 1 );

Then i tried changing the file /templates/checkout/form-checkout.php in my child theme and added

echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ) ) . '&nbsp;<a href="#" id="login-register">login / Register</a>';

no change whatsoever again.

In the code of the plugin sumosubscriptions, i didnt find any template changes of woocommerce_checkout_must_be_logged_in_message. in woocommerce-germanized pro, i found it in includes/checkout/ in step-address file. but i guess its not advised to add a file from includes folder in child-theme to change it.

at the moment, i have changed behaviour with js. has anyone an idea how to change it directly from template?
thanks in advance

How can I hide the “id?=1” in my URL in PHP [duplicate]

I have this code wherein I need to pass a data from one php to another so i declare it as

 <a  href=file1.php?id=$_POST['AccountID']).">
 <i class='fa fa-eye'></i></a>

but my problem is id=1 (the ID and the value of the ID shows in the URL) are there any ways to avoid this? I already tried using htaccess but it seems not working maybe because my website is built in MVC. I want to try to pass the data using jQuery but I don’t have any idea. Thank you for helping

WordPress redirect to previous “All Posts” list after Save post or Publish

I have many posts in my post custom post type and the “All Posts” is paged. When I click “Edit” link and want to edit some post, I want to auto redirect to real previous page I was.

For example I’m in the link https://example.com/wp-admin/edit.php?paged=18 and enter into edit one post. I want to redirect to mentioned link (page 18) after publish or edited post.

I tried a code but seems doesn’t work at all and it won’t redirect after publishing post or edit.

function wp_redirect_post_location( $location ) {
  $prevurl = $_SERVER['HTTP_REFERER'];
    if ( 'post' == get_post_type() ) {

        if ( isset( $_POST['save'] ) || isset( $_POST['publish'] ) )
            return $prevurl;

    } 
    return $location;
} 

add_filter( 'redirect_post_location', 'wp_redirect_post_location' );

And also tried this but didn’t worked:

add_action( 'wp_after_insert_post', 'redirect_after_save_post'); 

function get_redirect_url(){
  $prevurl = $_SERVER['HTTP_REFERER'];
    if (isset($_GET['post_type'])){
        $page = $_GET['post_type'];
        return $prevurl;
    }
}

function redirect_after_save_post($post_id){
    wp_redirect(get_redirect_url());
    exit;
}

The second code redirect to https://example.com/wp-admin/post.php after publishing post, while I want to redirect to https://example.com/wp-admin/edit.php?paged=18 (Where I entered to post’s edit).

Is there any solution or any other code to do this what I want? Thanks

How to get around “Unexpected reserved word” when installing Laravel Jetstream?

I am following the instructions at https://jetstream.laravel.com/installation.html for installing Laravel Jetstream.

I run artisan jetstream:install and choose to install with Livewire support, API support, email verification and PHPUnit support.

I then run npm install per the instructions, and everything seems to work.

Finally, I run npm run build per the instructions. Uh oh! I now get the following message:

> build
> vite build

file:///home/mrmayor/Documents/coding-projects/super-great-project/backend/node_modules/vite/bin/vite.js:7
    await import('source-map-support').then((r) => r.default.install())
    ^^^^^

SyntaxError: Unexpected reserved word
    at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
    at async link (internal/modules/esm/module_job.js:42:21)

Any idea what I’m doing wrong?

Php artisan not detecting declared route

I’m new to Laravel and try to run a program. In the source code, the route login.post already declared in web.php. however i still getting error Route [login.post] not defined.. Is there any missing configuration i missing? I already ran composer install and composer update. php artisan db:seed and php artisan migrate.

web,php

Route::get('login', [AuthController::class, 'index'])->name('login');
Route::post('post-login', [AuthController::class, 'postLogin'])->name('login.post'); 
Route::get('register', [AuthController::class, 'register'])->name('register');
Route::post('post-registration', [AuthController::class, 'postRegistration'])->name('register.post'); 
Route::get('logout', [AuthController::class, 'logout'])->name('logout');

Error picenter image description here

htaccess Rewrite doesn’t change the URL [duplicate]

I have tried a lot of different rules and conditions, but htaccess just doesn’t seem to work for me. I’m not even sure I understand how it works, please help.

I have a URL that looks like
advertisements/views/user-list.php
I’d like it to look like
advertisements/user-list

How would I achieve this? (this is for a localhost based URL)


MySQL UPDATE with JOIN failing

update  loan  l  
inner join (
        select LoanId, sum(Amount) as Amount 
        from    loanpayment  
        where   LoanId = pLoanId  
        )  as  lp on l.Id = lp.LoanId 

set  l.CurBalance = OriginalAmount + TermMonths *(OriginalAmount * MonthlyRate/100) 
                        - coalesce(lp.Amount,0) 
where   l.Id = pLoanId   ;   

The CurBalance is not being updated when I change the TermMonths. Am I missing something ?

Thanks. I am on mysql 7 and 8.

Elasticsearh needs to fix the query to look for a misspelled word

            $query = [
                'query' => [
                    'bool' => [
                        'should' => [],
                    ],
                ],
            ];

            $fields = ['name_original'];
            foreach ($fields as $field) {
                $matchQuery = [
                    'query_string' => [
                        'default_field' => $field,
                        'query' => '*' . $keyword . '*',
                        'fuzziness' => 'AUTO',
                    ],
                ];
                $query['query']['bool']['should'][] = $matchQuery;
            }

you need to search for a word written with an error, ‘fuzziness’ => ‘AUTO’ seems to be responsible for this, but for some reason it does not work

tried fuzziness’ => ‘AUTO’, analyzers, replaced query_string with match

Accessing certain fields from another Eloquent model

I am having such a terrible time trying to achieve a certain thing – I have a model A that needs to access model Profile’s column name for search functionality, but I have been getting all of A instead of “no search returned” or the specific search list. I am new to PHP.

Here’s my code.


// Model A (excerpt) (Models.php)

class A extends Model {
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function profile() {
        return $this->hasOneThrough(Profile::class, User::class, 'id', 'user_id', 'user_id');
   }
}

Model Profile

class Profile extends Model
{
    use HasFactory, UuidTrait;

    public $guarded = ['null'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

// my error is coming from below

UserController.php

....
if($search != "")
{
    $users->orWhereHas('A', function($query) use($search) {
       $query->where('A.first_name', 'LIKE', "${search}%"
    }

}

Model A columns: id, user_id, address, size
Model Profile columns: id, first_name, gender, user_id

Hence, the relationship of A to Profile is through user_id (say, A=>user_id=>profile.first_name)

Expected Result:

search ‘Fred’ (present in Profile)
return A fields with ‘Fred’ present

Actual Result:

no column A.first_name

Fatal error: Uncaught Error: Undefined constant “PhpOfficePhpSpreadsheetsrcPhpSpreadsheetIOFactory”

I Installed PhpSpreadsheet Using this command
composer require phpoffice/phpspreadsheet
and i run example codes in documentation and got error
for example this code:

<?php
$inputFileName = './book.xlsx';

/** Load $inputFileName to a Spreadsheet Object  **/
$spreadsheet = PhpOfficePhpSpreadsheetsrcPhpSpreadsheetIOFactory::load($inputFileName);
?>

I checked installed directory and this files exist :

    Directory: C:xampphtdocswebsitevendorphpofficephpspreadsheet

Mode                 LastWriteTime         Length Name                                                                 
----                 -------------         ------ ----                                                                 
d-----         8/31/2023   5:25 PM                src                                                                  
-a----         6/14/2023   3:48 PM          11084 .php-cs-fixer.dist.php                                               
-a----         6/14/2023   3:48 PM            752 .phpcs.xml.dist                                                                                                                     
-a----         6/14/2023   3:48 PM         112316 CHANGELOG.md                                                         
-a----         6/14/2023   3:48 PM           3799 composer.json                                                        
-a----         6/14/2023   3:48 PM           3136 CONTRIBUTING.md                                                      
-a----         6/14/2023   3:48 PM           1079 LICENSE                                                              
-a----         6/14/2023   3:48 PM           1076 phpstan-baseline.neon                                                
-a----         6/14/2023   3:48 PM           4101 phpstan-conditional.php                                              
-a----         6/14/2023   3:48 PM           1374 phpstan.neon.dist                                                    
-a----         6/14/2023   3:48 PM            617 phpunit10.xml.dist                                                   
-a----         6/14/2023   3:48 PM           6667 README.md 

and this directory :



    Directory: C:xampphtdocswebsitevendorphpofficephpspreadsheetsrcPhpSpreadsheet


Mode                 LastWriteTime         Length Name                                                                 
----                 -------------         ------ ----                                                                 
d-----         8/31/2023   5:25 PM                Calculation                                                          
d-----         8/31/2023   5:25 PM                Cell                                                                 
d-----         8/31/2023   5:25 PM                Chart                                                                
d-----         8/31/2023   5:25 PM                Collection                                                           
d-----         8/31/2023   5:25 PM                Document                                                             
d-----         8/31/2023   5:25 PM                Helper                                                               
d-----         8/31/2023   5:25 PM                Reader                                                               
d-----         8/31/2023   5:25 PM                RichText                                                             
d-----         8/31/2023   5:25 PM                Shared                                                               
d-----         8/31/2023   5:25 PM                Style                                                                
d-----         8/31/2023   5:25 PM                Worksheet                                                            
d-----         8/31/2023   5:25 PM                Writer                                                                                                                             
-a----         6/14/2023   3:48 PM           4358 CellReferenceHelper.php                                              
-a----         6/14/2023   3:48 PM           7531 Comment.php                                                          
-a----         6/14/2023   3:48 PM           6567 DefinedName.php                                                      
-a----         6/14/2023   3:48 PM             83 Exception.php                                                        
-a----         6/14/2023   3:48 PM           3846 HashTable.php                                                        
-a----         6/14/2023   3:48 PM            182 IComparable.php                                                      
-a----         6/14/2023   3:48 PM           9020 IOFactory.php                                                        
-a----         6/14/2023   3:48 PM            973 NamedFormula.php                                                     
-a----         6/14/2023   3:48 PM           1250 NamedRange.php                                                       
-a----         6/14/2023   3:48 PM          55334 ReferenceHelper.php                                                  
-a----         6/14/2023   3:48 PM           6145 Settings.php                                                         
-a----         6/14/2023   3:48 PM          46390 Spreadsheet.php                                                      
-a----         6/14/2023   3:48 PM           7171 Theme.php                                                            

i tried to reinstall but got this error again

PHP how to display errors after script finnished loading?

I already use:

ini_set('display_errors', '1');
 ini_set('display_startup_errors', '1');
 error_reporting(E_ALL);

at the beginning of my code. However, the error messages are displayed directly in the output (wich is a lot, so you can’t find the errors well).

How do I display all the errors that occured, after the script is done loading?

How to enable subscription product in paypal checkout SDK

I am trying to add subscription in paypal checkout and I am using paypal checkout SDK but this not working

$environment = new PayPalCheckoutSdkCoreSandboxEnvironment(PAYPAL_SANDBOX_CLIENT_ID, 
PAYPAL_SANDBOX_CLIENT_SECRET);
$client = new PayPalCheckoutSdkCorePayPalHttpClient($environment);

$request = new PayPalCheckoutSdkOrdersOrdersCreateRequest();
$request->prefer('return=representation');

$subscription = ['plan_id' => '23423432',
'start_time' => '2023-09-01T00:00:00Z', 
'quantity' => 1];

$request->body = [
"intent" => "CAPTURE",
"purchase_units" => [[
    "reference_id" => $orderInfo['id'],
    "amount" => [
    "value" => $orderInfo['total'],
    "currency_code" => "AUD"
    ],
    'subscription' => $subscription,
]],
    "application_context" => [
        "cancel_url" => FRONTEND_APP_URL."order-status/?pstatus=payment-declined&source=paypal",
        "return_url" => FRONTEND_APP_URL."order-status/?pstatus=payment-processing&source=paypal"
    ] 
];

But in paypal nothing showing related to subscription. Please let me know how i can fix that

How to comment a php line in which there is a condition

How to comment a php line in which there is a condition in a form whose html and css style I am editing locally on my wamp server.
The form works perfectly online but if I don’t comment out the php, I can’t see the rendering (it works with a database and variables).

Only one line is giving me trouble, it’s the line where there is the condition count($errors)>0 🙁

<form action="en_login.php" method="post">
                <h3 class="text-center text-5xl font-Helvetica">Login</h3>
                
                <?php  if (count($errors)>0) {  ?>

                <div class="alert">
                    <?php // foreach ($errors as $error) { ?>
                    <li><?php // echo $error; ?></li>
                    <?php // } ?>
                </div>
                <?php // } ?>
                                

Impossible to not get ” 0) { ?> ” in my html