Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

Add possibility to set custom properties to cart item#143

Merged
fashxp merged 11 commits into
pimcore:1.xfrom
dblaichinger:add-custom-properties-to-cart-item
Feb 5, 2024
Merged

Add possibility to set custom properties to cart item#143
fashxp merged 11 commits into
pimcore:1.xfrom
dblaichinger:add-custom-properties-to-cart-item

Conversation

@dblaichinger

@dblaichinger dblaichinger commented Dec 14, 2023

Copy link
Copy Markdown

Overview

The suggested change would make it easier to extend CartItem class and provide the property in Cart::addItem() as $params afterwards.

Extend CartItem

The $params parameter in AbstractCart::addItem is currently unused in this method, but the doc-block suggests that it's possible to add additional data.

In src/CartManager/CartInterface.php:

/**
* @param CheckoutableInterface $product
* @param int $count
* @param string|null $itemKey
* @param bool $replace replace if item with same key exists
* @param array $params optional additional item information
* @param AbstractSetProductEntry[] $subProducts
* @param string|null $comment
*
* @return string $itemKey
*/
public function addItem(CheckoutableInterface $product, int $count, string $itemKey = null, bool $replace = false, array $params = [], array $subProducts = [], string $comment = null): string;


Also see:

Daniel Blaichinger added 3 commits December 14, 2023 09:27
…chinger/ecommerce-framework-bundle into add-custom-properties-to-cart-item
@github-actions

github-actions Bot commented Dec 15, 2023

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@bluvulture

Copy link
Copy Markdown
Contributor

Hey @dblaichinger

Could you plase sign cla and then re-trigger the check?

Tnx

Comment thread src/CartManager/AbstractCart.php Outdated
Co-authored-by: Sebastian Blank <sebastian.bl@gmx.de>
@dblaichinger

Copy link
Copy Markdown
Author

recheck

Daniel Blaichinger added 2 commits December 15, 2023 13:43
…chinger/ecommerce-framework-bundle into add-custom-properties-to-cart-item
…chinger/ecommerce-framework-bundle into add-custom-properties-to-cart-item
@dblaichinger

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Daniel Blaichinger added 2 commits December 15, 2023 13:57
…chinger/ecommerce-framework-bundle into add-custom-properties-to-cart-item
…chinger/ecommerce-framework-bundle into add-custom-properties-to-cart-item
@fashxp

fashxp commented Dec 15, 2023

Copy link
Copy Markdown
Member

Can we do that without changing an interface? As it is now it would be a bc break

@dblaichinger

Copy link
Copy Markdown
Author

Hi @fashxp,

I've removed the interface change in this PR and added a method_exists check instead.
However, I still think it's cleaner to extend the interface, so I've added a new #146. Can you please add the BC-BREAK label there and remove it from this one?

Thank you!

@fashxp

fashxp commented Jan 29, 2024

Copy link
Copy Markdown
Member

@dblaichinger thx very much. added some docs, can you please double check?
also thought that it might be really cool, if the custom properties would be stored automatically and extending Cart/CartItem isn't even necessary.
But that might require a bit more refactoring.

@dblaichinger

Copy link
Copy Markdown
Author

Hi @fashxp

added some docs, can you please double check?

I've added some details, please check b43fa91

also thought that it might be really cool, if the custom properties would be stored automatically and extending Cart/CartItem isn't even necessary.

Can this be achieved without changing CartItemInterface and breaking compatibility?

I've added $customProperties to AbstractCartItem in the BC-BREAK tagged PR: https://github.com/pimcore/ecommerce-framework-bundle/pull/146/files. Maybe that's a better approach when already breaking compatibility.

Thanks!

@fashxp

fashxp commented Feb 5, 2024

Copy link
Copy Markdown
Member

I've added $customProperties to AbstractCartItem in the BC-BREAK tagged PR: https://github.com/pimcore/ecommerce-framework-bundle/pull/146/files. Maybe that's a better approach when already breaking compatibility.

not sure if we really need to add an additional parameter, of if we just add a generic functionality to the existing cart implementations, which persists the data passed via $params parameter to their storage. Let's continue the discussion over there in the other PR.

This one looks good now. Thx very much!!

@fashxp fashxp added this to the 1.1.0 milestone Feb 5, 2024
@fashxp fashxp merged commit 7fd7dfc into pimcore:1.x Feb 5, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 5, 2024
@dblaichinger dblaichinger deleted the add-custom-properties-to-cart-item branch February 5, 2024 10:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants