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

Can't delete Payment Method #1119

Closed
dathwa opened this issue May 2, 2024 · 5 comments
Closed

Can't delete Payment Method #1119

dathwa opened this issue May 2, 2024 · 5 comments

Comments

@dathwa
Copy link

dathwa commented May 2, 2024

Hello.
Mall 3.2.1.
I click delete payment method, I get the message "Deleted selected records", but nothing happens. No errors.
Thanks.

@SamBrishes
Copy link
Collaborator

Hello,

Strange. I tried it myself and was able to delete everything without any issues, even the default payment option.

Is there perhaps an error written in the storage/log/system.log file? It's best to empty this file and perform the operation again so that there are no overlaps with other errors.

Which DB System / OctoberCMS version are you using?

Sincerely,
Sam.

@SamBrishes
Copy link
Collaborator

Hello,

closing this issue for now. Please update to the latest version, and if the error occur again, please re-open this issue and check out your storage/log/system.log file.

Thanks.

~ Sam.

@dathwa
Copy link
Author

dathwa commented Jun 5, 2024

Hi @SamBrishes
OCMS 3.6.22. Mall 3.3.1.
It's nuts, but I still have this issue. See video
I have all my debug flags on, but no errors at all.
I've added trace logs in the 2 methods below for OFFLINE\Mall\Models\PaymentMethod, so something is kicking in, but the deleted_at columns are still empty.

See Trait SoftDelete - I noticed the model was missing protected $dates = ['deleted_at']; - i tried adding this but it makes no difference.
What to do? I guess I can just manually update the deleted_at date for now. Thanks.

public function beforeDelete()
    {
        trace_log(__METHOD__);
        trace_log(post());
    }

    /**
     * Hook after model has been deleted.
     * @return void
     */
    public function afterDelete()
    {
        trace_log(__METHOD__);

        DB::table('offline_mall_prices')
           ->where('priceable_type', self::MORPH_KEY)
           ->where('priceable_id', $this->id)
           ->delete();
    }
[2024-06-05 09:20:18] development.INFO: OFFLINE\Mall\Models\PaymentMethod::beforeDelete  
[2024-06-05 09:20:18] development.INFO: Array
(
    [checked] => Array
        (
            [0] => 7
        )

)
  
[2024-06-05 09:20:18] development.INFO: OFFLINE\Mall\Models\PaymentMethod::afterDelete  

@SamBrishes
Copy link
Collaborator

Hello,

After a little code deep dive I found the error. The used method of Octobers SoftDeletes trait creates a completely new query (instead of using the model itself) whereupon the is_enabled statement is automatically added again and thus of course prevents disabled elements from being deleted.

No idea why it worked for me sometimes, but now it should work in general.

Anyways. fix is in next branch, should be part of 3.3.2

Sincerely,
Sam.

@dathwa
Copy link
Author

dathwa commented Jun 6, 2024

Excellent sleuthing @SamBrishes
I'll confirm if it works for me next update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants