oc-mall-plugin icon indicating copy to clipboard operation
oc-mall-plugin copied to clipboard

Can't delete Payment Method

Open dathwa opened this issue 9 months ago • 1 comments

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

dathwa avatar May 02 '24 08:05 dathwa

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 avatar May 02 '24 13:05 SamBrishes

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.

SamBrishes avatar Jun 03 '24 20:06 SamBrishes

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  

dathwa avatar Jun 05 '24 09:06 dathwa

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.

SamBrishes avatar Jun 06 '24 08:06 SamBrishes

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

dathwa avatar Jun 06 '24 09:06 dathwa

Yip. Working for me.

dathwa avatar Jul 23 '24 10:07 dathwa