Skip to content

Conversation

@kshojib
Copy link
Contributor

@kshojib kshojib commented Apr 7, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes #37613.

After reviewing the code in plugins/woocommerce/includes/class-wc-cart.php, I saw that the variation id was not being added to the in_cart array. Instead, the parent id was added.
I added a condition to check if the product is a variation product. Then added the variation id to the array. That solved the problem

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Go to the Product edit page of any product.
  2. Scroll down to Product data → Linked Products
  3. Add a variable product to Cross-sells.
  4. Preview the changes and add the edited product to the cart.
  5. Click "View cart" and you will see the linked cross-sells product being displayed under "You may be interested in…" on the cart page.
  6. Add the Cross-sells product to the cart.
  7. You should see the product is not showing in cross-sells anymore.

@woocommercebot woocommercebot requested review from a team, Konamiman, chihsuan and moon0326 and removed request for a team April 7, 2023 07:38
@chihsuan
Copy link
Member

chihsuan commented Apr 7, 2023

Hey @kshojib It seems that this PR contains #37583 changes. Could you update this branch so it only includes display card-related changes?

--

ChatGPT

To drop or remove some commits using Git, you can use an interactive rebase. Here's a step-by-step guide:

  1. Make sure you're on the branch that contains the commits you want to remove.
    bash
    git checkout <branch_name>
  2. Identify the commit hash (or reference) that is before the first commit you want to drop. You can use git log to get a list of commit hashes and their corresponding messages.
  3. Start an interactive rebase using the commit hash (or reference) you identified in step 2.
    bash
    git rebase -i <commit_hash>
  4. Your default text editor will open a file that lists the commits in chronological order. Each line represents a commit starting with the word "pick", followed by the commit hash and commit message.
  5. To drop a commit, change the word "pick" to "drop" (or "d") for the commits you want to remove. For example:
    pick 1a2b3c4 First commit message
    drop 2b3c4d5 Second commit message (The commit you wish to drop)
    pick 3c4d5e6 Third commit message
  6. Save and close the file. Git will process the changes and remove the specified commits.
  7. Finally, the branch's history has changed, so you might need to use a force push to update the remote branch:
    bash
    git push --force-with-lease
    Note: Be careful when force pushing, as it can overwrite changes made by others. Communicate with your team before performing a force push to avoid undesired consequences.

@kshojib kshojib force-pushed the fix/37613-cross-sells-display-cart branch from fd8e911 to dd6dc62 Compare April 7, 2023 11:48
@chihsuan chihsuan removed request for a team, chihsuan and moon0326 April 12, 2023 01:58
@chihsuan
Copy link
Member

This is the product editing area. I just unassigned PR review from Ghidorah and let @woocommerce/mothra review it.

@Konamiman Konamiman added the Product/Inventory Management Issues related to product or product page. label Apr 12, 2023
@Konamiman Konamiman removed their request for review April 12, 2023 08:06
@kshojib
Copy link
Contributor Author

kshojib commented Apr 21, 2023

Hi, Just wanted to check in on my pull request and see if you had a chance to take a look yet. Any feedback would be greatly appreciated. Let me know if there's anything I can do to help move things along.

@mattsherman mattsherman added Cart Issues related to the cart. and removed Product/Inventory Management Issues related to product or product page. labels Apr 24, 2023
@mattsherman
Copy link
Contributor

@kshojib I am unable to reproduce the original issue #37613...

When I add a variable product (PRODUCT B) as a cross-sell of another product (PRODUCT A) and then add PRODUCT A to my cart, PRODUCT B is shown as "you may be interested in". When I then add PRODUCT B to my cart, it is removed from "you may be interested in". This sticks even after refreshing my cart page.

I'm looping in @woocommerce/proton, that work more closely with the cart code, so that they can review both the original issue (#37613) and this PR to determine if there is an issue still and if this PR addresses the issue.

@barryhughes
Copy link
Member

Please see updates in #37613. Thanks to @stoltzrx, I was able to replicate: the key component is to add a variant (child product) rather than the variable (parent).

cc @mattsherman (also, fine to reassign to a Proton reviewer if you prefer).

Copy link
Contributor

@mattsherman mattsherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job on this, @kshojib ! Thanks for submitting this PR to fix this scenario.

@mattsherman mattsherman merged commit 0ae9ec0 into woocommerce:trunk May 2, 2023
@github-actions github-actions bot added this to the 7.8.0 milestone May 2, 2023
@kshojib kshojib deleted the fix/37613-cross-sells-display-cart branch May 2, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cart Issues related to the cart. plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-Sells display variable product even after adding these to the Cart

5 participants