Skip to content

Commit

Permalink
Fix bundle products (#53)
Browse files Browse the repository at this point in the history
* Fix bundle products, update version to 5.1.5, and update plugin version to 5.1.5

* Refactor code to improve readability and remove unnecessary variables.

* Update CHANGELOG.md with version 5.1.5 and fix bundle products

This commit updates the CHANGELOG.md file to reflect the new version 5.1.5. It also includes a fix for bundle products, addressing any issues related to them.

* fix empty space
  • Loading branch information
fcarrero authored Oct 30, 2024
1 parent b189226 commit 05f329d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 5.1.5 - 2024/10/28
* Fix:
- Fix bundle products
### 5.1.4 - 2024/07/18
* Fix:
- Fix recovery orders when quote has not a valid shipping address
Expand Down
26 changes: 16 additions & 10 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ public function getLineItems(array $items, $isQuoteItem = true): array
$version = (int)str_replace('.', '', $this->getMageVersion());
$request = [];
$quantityMethod = $isQuoteItem ? "getQty" : "getQtyOrdered";
$processedBundleItems = [];

foreach ($items as $item) {
if ($version > 233) {
if ($item->getProductType() != 'bundle' && $item->getProductType() != 'configurable') {
Expand All @@ -490,22 +492,26 @@ public function getLineItems(array $items, $isQuoteItem = true): array
$sku = $this->removeSpecialCharacter($item->getSku());
$productId = $item->getProductId();
$productType = $item->getProductType();
if (! empty($item->getParentItem())) {
if (!empty($item->getParentItem())) {
$parent = $item->getParentItem();

if ($parent->getProductType() == 'configurable') {
$price = $item->getParentItem()->getPrice();
$qty = (int)$item->getParentItem()->{$quantityMethod}();
} elseif ($parent->getProductType() == 'bundle' && $isQuoteItem) {
//If it is a quote item, then qty of item has not been calculated yet
$qty = $item->getParentItem()->getQty();
$price = $item->getParentItem()->getPrice();
$name = $this->removeSpecialCharacter($item->getParentItem()->getName());
$sku = $this->removeSpecialCharacter($item->getParentItem()->getSku());
$productId = $item->getParentItem()->getProductId();
$productType = $item->getParentItem()->getProductType();


// Verificar si el bundle product ya ha sido procesado
if (in_array($parent->getId(), $processedBundleItems)) {
continue;
}
$processedBundleItems[] = $parent->getId();

// Si es un quote item, entonces la cantidad del item no ha sido calculada aún
$qty = $parent->getQty();
$price = $parent->getPrice();
$name = $this->removeSpecialCharacter($parent->getName());
$sku = $this->removeSpecialCharacter($parent->getSku());
$productId = $parent->getProductId();
$productType = $parent->getProductType();
}
}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![alt tag](https://conekta.com/static/assets/Home/conekta-logo-blue-full.svg)

Magento 2 Plugin v.5.1.4 (Stable)
Magento 2 Plugin v.5.1.5 (Stable)
========================

Installation for Magento 2.3
Expand All @@ -13,7 +13,7 @@ composer config repositories.conekta git https://github.com/conekta/customer-mag

2. Add composer dependency
```bash
composer require conekta/conekta_payments 5.1.4
composer require conekta/conekta_payments 5.1.5
```

3. Update Magento
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"conekta/conekta-php": "v6.0.8"
},
"type": "magento2-module",
"version": "5.1.4",
"version": "5.1.5",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<system>
<section id="payment">
<group id="conekta" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
<comment><![CDATA[<div class="conekta-payment-logo"></div><div class="conekta-payment-text">Conekta Configuration. (v5.1.4) </div>]]></comment>
<comment><![CDATA[<div class="conekta-payment-logo"></div><div class="conekta-payment-text">Conekta Configuration. (v5.1.5) </div>]]></comment>
<fieldset_css>complex conekta-section</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<!--global-->
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<global>
<api_version><![CDATA[2.0.0]]></api_version>
<plugin_type><![CDATA[Magento 2]]></plugin_type>
<plugin_version><![CDATA[5.1.4]]></plugin_version>
<plugin_version><![CDATA[5.1.5]]></plugin_version>
</global>
</conekta>
</default>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Conekta_Payments" setup_version="5.1.4">
<module name="Conekta_Payments" setup_version="5.1.5">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down

0 comments on commit 05f329d

Please sign in to comment.