Skip to content

Commit

Permalink
Add OneClick button to virtual product (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
rus-daniel committed Feb 19, 2018
1 parent 7664a4e commit 0c8bc5f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/code/community/Oyst/OneClick/Model/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Oyst_OneClick_Model_Catalog extends Mage_Core_Model_Abstract
Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
Mage_Catalog_Model_Product_Type::TYPE_GROUPED,
//Mage_Catalog_Model_Product_Type::TYPE_BUNDLE,
//Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
//Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE,
);

Expand Down
24 changes: 24 additions & 0 deletions app/code/community/Oyst/OneClick/Model/OneClick/ApiWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function authorizeOrder($dataFormated)
}

$orderParams = $this->getOneClickOrderParams();
$orderParams->setIsMaterialized($this->productsAreMaterialized($oystProducts));
$context = $this->getContext();

try {
Expand Down Expand Up @@ -163,4 +164,27 @@ private function getContext()

return $context;
}

/**
* Check if all products are materialized.
*
* @param $oystProducts
*
* @return bool
*/
private function productsAreMaterialized($oystProducts)
{
$productModel = Mage::getModel('catalog/product');
$materialised = false;

foreach ($oystProducts as $oystProduct) {
$product = $productModel->load($oystProduct->reference);

if ($product->getTypeId() !== Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL) {
$materialised = true;
}
}

return $materialised;
}
}
1 change: 1 addition & 0 deletions skin/frontend/base/default/js/oyst/oneclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function oystOneClick(productTypeId, oneClickUrl, isProductAddtocartFormValidate
var productId, quantity, configurableProductChildId, superGroupEl, productsEl;
switch (productTypeId) {
case "simple":
case "virtual":
// [Hook] Custom function allow anyone to use custom function to retrieve product id
productId = "function" === typeof customGetProductId ?
customGetProductId() :
Expand Down

0 comments on commit 0c8bc5f

Please sign in to comment.