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

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

Open
jlachancekffein opened this issue Aug 19, 2020 · 1 comment

Comments

@jlachancekffein
Copy link

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)

@peteeveleigh
Copy link

Didn't see this here and have submitted a pull request with essentially the same fix
#41

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

No branches or pull requests

2 participants