Jump to content

How to sell virtual products with combinations like store.nemops.com


Recommended Posts

Hi, im newby and trying to configure my store 1.6 to sell virtual products, and would like to add extras features to the product, just like this image.

 

Changing combinations change prices.

 

But in my 1.6 says that virtual product can not have combinations, how to configure then ?

 

3pX5nM5.png

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hi there!

 

I was able to make Nemo1's tutorial work with Prestashop 1.6 :D

 

There's just one additional step compared to version 1.5. You need to override form.tpl (controllers/admin/templates/products/helpers/form) and there, comment out line 116. Basically, this is the original code:

else if (product_type == product_type_virtual)

                {

                    $('a[id*="Pack"]').hide();

                    $('a[id*="Shipping"]').hide();

                    $('a[id*="Combinations"]').hide();

                }[

and this should be the final one:

else if (product_type == product_type_virtual)

                {

                    $('a[id*="Pack"]').hide();

                    $('a[id*="Shipping"]').hide();

                    //$('a[id*="Combinations"]').hide();

                }

Hope this helps :)

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Hi there!

 

I was able to make Nemo1's tutorial work with Prestashop 1.6 :D

 

There's just one additional step compared to version 1.5. You need to override form.tpl (controllers/admin/templates/products/helpers/form) and there, comment out line 116. Basically, this is the original code:

else if (product_type == product_type_virtual)

                {

                    $('a[id*="Pack"]').hide();

                    $('a[id*="Shipping"]').hide();

                    $('a[id*="Combinations"]').hide();

                }[

and this should be the final one:

else if (product_type == product_type_virtual)

                {

                    $('a[id*="Pack"]').hide();

                    $('a[id*="Shipping"]').hide();

                    //$('a[id*="Combinations"]').hide();

                }

Hope this helps :)

 

i followed every step till i reached to yours 

i dont have the folders !

controllers/admin/templates/products/helpers/form

there are no folders after controllers/admin/

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

I'm trying to implement this override with PS 1.6.0.9 and am having an issue with the scricpt failing at line 67

 

else
        {
            $data->assign('product', $product);
            $this->displayWarning($this->l('You must save this product before adding combinations.'));
        }

 

I'm not great at PHP - do I have something wrong with the override file? I've posted the content of the file below.

 

Thanks! and any help is greatly appreciated.

 

<?php
class AdminProductsController extends AdminProductsControllerCore
{
public function initFormAttributes($product)
    {
        $data = $this->createTemplate($this->tpl_form);
        if (!Combination::isFeatureActive())
            $this->displayWarning($this->l('This feature has been disabled. ').
                ' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
        else if (Validate::isLoadedObject($product))
        {
             if ($this->product_exists_in_shop)
             //{
                // if ($product->is_virtual)
                 //{
                     //$data->assign('product', $product);
                     //$this->displayWarning($this->l('A virtual product cannot have combinations.'));
                 //}
                 //else
                 {
                    $attribute_js = array();
                    $attributes = Attribute::getAttributes($this->context->language->id, true);
                    foreach ($attributes as $k => $attribute)
                        $attribute_js[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name'];
                    $currency = $this->context->currency;
                    $data->assign('attributeJs', $attribute_js);
                    $data->assign('attributes_groups', AttributeGroup::getAttributesGroups($this->context->language->id));

                    $data->assign('currency', $currency);

                    $images = Image::getImages($this->context->language->id, $product->id);

                    $data->assign('tax_exclude_option', Tax::excludeTaxeOption());
                    $data->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT'));

                    $data->assign('ps_use_ecotax', Configuration::get('PS_USE_ECOTAX'));
                    $data->assign('field_value_unity', $this->getFieldValue($product, 'unity'));

                    $data->assign('reasons', $reasons = StockMvtReason::getStockMvtReasons($this->context->language->id));
                    $data->assign('ps_stock_mvt_reason_default', $ps_stock_mvt_reason_default = Configuration::get('PS_STOCK_MVT_REASON_DEFAULT'));
                    $data->assign('minimal_quantity', $this->getFieldValue($product, 'minimal_quantity') ? $this->getFieldValue($product, 'minimal_quantity') : 1);
                    $data->assign('available_date', ($this->getFieldValue($product, 'available_date') != 0) ? stripslashes(htmlentities($this->getFieldValue($product, 'available_date'), $this->context->language->id)) : '0000-00-00');

                    $i = 0;
                    $data->assign('imageType', ImageType::getByNameNType('small_default', 'products'));
                    $data->assign('imageWidth', (isset($image_type['width']) ? (int)($image_type['width']) : 64) + 25);
                    foreach ($images as $k => $image)
                    {
                        $images[$k]['obj'] = new Image($image['id_image']);
                        ++$i;
                    }
                    $data->assign('images', $images);

                    $data->assign($this->tpl_form_vars);
                    $data->assign(array(
                        'list' => $this->renderListAttributes($product, $currency),
                        'product' => $product,
                        'id_category' => $product->getDefaultCategory(),
                        'token_generator' => Tools::getAdminTokenLite('AdminAttributeGenerator'),
                        'combination_exists' => (Shop::isFeatureActive() && (Shop::getContextShopGroup()->share_stock) && count(AttributeGroup::getAttributesGroups($this->context->language->id)) > 0 && $product->hasAttributes())
                    ));
                }
            }
            else
                $this->displayWarning($this->l('You must save the product in this shop before adding combinations.'));    
        }
        else
        {
            $data->assign('product', $product);
            $this->displayWarning($this->l('You must save this product before adding combinations.'));
        }

        $this->tpl_form_vars['custom_form'] = $data->fetch();
    }
   }

Link to comment
Share on other sites

  • 1 year later...
  • 4 weeks later...

Cannot find this route at all:

themes/default/template/controllers/products

 

I know the default theme now is default-bootstrap, but I cannot find any template, or controllers anywhere... So I cannot use those files to replicate. I don't know if it's pretty obvious what I'm missing, but I cannot find anything! 

Link to comment
Share on other sites

  • 1 month later...

Hey there, just wanted to jump on this thread since it's related to Nemo's modifications (thanks for making a tutorial by the way!)

 

I've followed every single step and am running the latest Prestashop version 1.6.1.5. It looks like something is still causing issues as I'm still getting the "You cannot use combinations with a virtual product" message and the combination tab disappears when I create a new virtual product.

 

All this is very odd because every single modification is supposed to get rid of those exact things. I even went ahead and turned off the cache completely. I don't know what's missing; any pointers?

 

I've attached the AdminProductsController.php here for you to take a look and see if there's anything that seems to conflict?

 

Thanks in advance!

AdminProductsController.php

Edited by Ascalion (see edit history)
Link to comment
Share on other sites

WHich files can't you locate? I am still using 1.5 so I guess any could have changed their location since then. The admin products controller is still there though

 

Also just in case you'd like to update your tutorial for the newer version too with a note for 1.6, one thing changed location:

 

1. admin-products.js is now: js/admin/products.js

Link to comment
Share on other sites

  • 10 months later...

Has anyone attempted this tutorial with 1.7.x?

 

We have a need to sell virtual products with combinations but they are not downloadable products. We are selling memberships. There are several types of memberships that have varying times (1 week, 1 month, 3 months, 6 months, 1 year) as well as per use passes like (single use, 5 pack, 10, pack, 20 pack). And all of this is based on different types of memberships at the complex, like MMA, Karate, Boxing, Tactical Defence, Kick Boxing. We even have some MMA + Boxing combination memberships. The total number of combinations is well over 100. We want to leverage the whole "combinations" feature of regular products, but of course, there is nothing to ship or pickup in store when it comes to a membership. And then to create the combinations manually is not only time consuming, but from a UI and end user experience perspective, this is really painful.

 

If anyone can give me tips on what I should do, please advise. If it means trying to retrofit the tutorial to 1.7, I will need some guidance as well.

 

Thanks,

Nick

Link to comment
Share on other sites

  • 1 year later...

We are close to 2019 with Prestashop v1.7.4.4 and they still haven't added this simple feature in any updates!

I wonder why? I don't see the need to spend a lot of money for something this simple that was actually available in older PS versions.

Im also not a fan of changing some codes in core files because that would make it hard to test and make sure it works and to also doesn't face problems with other modules and PS future updates.

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...