Skip to content

Syncing promotions is broken. enabled key value need to be boolean #37

Open
@jlachancekffein

Description

@jlachancekffein

This endpoint : ecommerce/stores/{store_id}/promo-rules
Params: enabled

Need to be boolean. This crash because craft\commerce\models\Discount->enabled return a string and Mailchimp API claims that the type should be a boolean.

Here my fix:
/src/craftCMS/vendor/ether/mailchimp-commerce/src/services/PromosService.php

private function _buildPromoData($promoId){
...
$data = [
            'id' => (string) $promo->id,
            'title' => $promo->name,
            'description' => $promo->description ?: $promo->name,
            'amount' => (float) $amount,
            'type' => $type,
            'target' => $target,
            'enabled' => filter_var($promo->enabled, FILTER_VALIDATE_BOOLEAN),
            'created_at_foreign' => $promo->dateCreated->format('c'),
            'updated_at_foreign' => $promo->dateUpdated->format('c'),
        ];
...
}

filter_var($promo->enabled, FILTER_VALIDATE_BOOLEAN)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions