owen2345 / camaleon-ecommerce

This is an ecommerce plugin for CAMALEON CMS
MIT License
21 stars 20 forks source link

Having different prices for different attributes for the same product #24

Closed rroveri closed 8 years ago

rroveri commented 8 years ago

It would be useful to have different prices for different versions of the same product (red, green, blue, ...)

owen2345 commented 8 years ago

Hi @rroveri Good idea!

mazharoddin commented 8 years ago

Hi @owen2345,

Yeah its nice to have variants, but while implementing this feature if possible refer to Shopify implementation once, adding variants can be very confusing if its not properly implemented. I am attaching few screen shots from Shopify create product page.

screen shot 2016-06-16 at 18 46 10 screen shot 2016-06-16 at 18 46 50 screen shot 2016-06-16 at 18 49 20

Also please note that only Shopify automatically creates SKUs for variants, really its useful feature to have SKUs get created automatically for variants, otherwise it would be confusing for users. Also pls plan to upload individual image upload for variants, so that each variant has different image, if there are no images uploaded then it will show from main product. screen shot 2016-06-16 at 19 00 31 screen shot 2016-06-16 at 19 01 02

owen2345 commented 8 years ago

@mazharoddin it appears complex hehe!

mazharoddin commented 8 years ago

@oweb2345, for you it won't be complex :)

owen2345 commented 8 years ago

but, I was looking for some job to get some money, because I was fulltime with Camaleon without getting money. hehe!

mazharoddin commented 8 years ago

@owen2345 , true ...money also important factor..I agree ... Whenever you feel or try to implement ..then consider shopify implementation, otherwise it may be really confusing ..now even without this option product pages are useful, atleast they are not complex.

owen2345 commented 8 years ago

Hi @mazharoddin I added the product variations, could you please test it?

Regards,

mazharoddin commented 8 years ago

Sure @owen2345...Thanks

mazharoddin commented 8 years ago

Hi @owen2345, I am unable to test, I am getting below error while trying to add variant image.

Completed 500 Internal Server Error in 180ms (ActiveRecord: 3.8ms)

MiniMagick::Error (`mogrify -resize nullx /var/folders/kc/y4gc2tps1pxdv5ty4n4syjp80000gn/T/mini_magick20160709-13273-eqaa99.jpg` failed with error:
mogrify: invalid argument for option `nullx': -resize @ error/mogrify.c/MogrifyImageCommand/5799.
):
  mini_magick (4.5.1) lib/mini_magick/shell.rb:18:in `run'
  mini_magick (4.5.1) lib/mini_magick/tool.rb:92:in `call'
  mini_magick (4.5.1) lib/mini_magick/tool.rb:40:in `new'
  mini_magick (4.5.1) lib/mini_magick/image.rb:504:in `mogrify'
  mini_magick (4.5.1) lib/mini_magick/image.rb:384:in `combine_options'
  /Users/mazharoddin/.rvm/gems/ruby-2.2.2@rails4.2.5/bundler/gems/camaleon-cms-55fcf12d0190/app/helpers/camaleon_cms/uploader_helper.rb:145:in `cama_crop_image'
  /Users/mazharoddin/.rvm/gems/ruby-2.2.2@rails4.2.5/bundler/gems/camaleon-cms-55fcf12d0190/app/helpers/camaleon_cms/uploader_helper.rb:245:in `cama_resize_upload'
  /Users/mazharoddin/.rvm/gems/ruby-2.2.2@rails4.2.5/bundler/gems/camaleon-cms-55fcf12d0190/app/helpers/camaleon_cms/uploader_helper.rb:39:in `upload_file'
  /Users/mazharoddin/.rvm/gems/ruby-2.2.2@rails4.2.5/bundler/gems/camaleon-cms-55fcf12d0190/app/controllers/camaleon_cms/admin/media_controller.rb:79:in `upload'

I tried to update ImageMagick on my Mac, but I already have latest version,

brew upgrade ImageMagick
Error: imagemagick 6.9.2-7 already installed
mazharoddin commented 8 years ago

hi @owen2345, I am getting below error if I try to add a product without variants.

undefined method `keys' for nil:NilClass
Extracted source (around line #79):
  def ecommerce_admin_product_created(args)
    if args[:post_type].slug == 'commerce'
      args[:post].product_variations.where.not(id: params[:product_variation].keys).delete_all
      params[:product_variation].each do |p_key, p_var|
        data = {amount: p_var[:price], photo: p_var[:photo], sku: p_var[:sku], weight: p_var[:weight], qty: p_var[:qty], attribute_ids: p_var[:attributes].map{|at| at[:value] }.join(',')}
        if p_key.include?('new_') # new variation

vendor/plugins/camaleon-ecommerce/app/helpers/plugins/ecommerce/ecommerce_helper.rb:79:in `ecommerce_admin_product_created'

Here is the repository details.

github.com:mazharoddin/camaleon_cms_debug.git

-Thanks.

owen2345 commented 8 years ago

@mazharoddin Fixed variations! I tried many times to reproduce the imagemagick problem, but without success.

mazharoddin commented 8 years ago

Sure np, Let me re-try. Thanks.

mazharoddin commented 8 years ago

@owen2345 ,

Now I am able to create product with variants. But I am getting below error if I try to create a variant without adding product attributes.

undefined method `map' for nil:NilClass
      args[:post].product_variations.where.not(id: params[:product_variation].keys).delete_all
      params[:product_variation].each do |p_key, p_var|
        data = {amount: p_var[:price], photo: p_var[:photo], sku: p_var[:sku], weight: p_var[:weight], qty: p_var[:qty], attribute_ids: p_var[:attributes].map{|at| at[:value] }.join(',')}
        if p_key.include?('new_') # new variation
          args[:post].product_variations.create(data)
        else
vendor/plugins/camaleon-ecommerce/app/helpers/plugins/ecommerce/ecommerce_helper.rb:82:in `block in ecommerce_admin_product_created'
actionpack (4.2.6) lib/action_controller/metal/strong_parameters.rb:185:in `each_pair'

Can you please create some default 'Product Attributes' whenever user activates eCommerce plugin.

Color, Size and material etc attributes are commonly used, these can be created by default. What do you think.

Imagemagick error I am getting only with variants images, normal product image upload is working fine with out any issue. I am unable to insert existing images in variants.

screen shot 2016-07-12 at 18 07 57

If I try to upload new image I am getting this error.

screen shot 2016-07-12 at 18 09 34

Completed 500 Internal Server Error in 86ms (ActiveRecord: 1.1ms)

MiniMagick::Error (`mogrify -resize nullx /var/folders/kc/y4gc2tps1pxdv5ty4n4syjp80000gn/T/mini_magick20160712-30646-idd5h3.jpg` failed with error:
mogrify: invalid argument for option `nullx': -resize @ error/mogrify.c/MogrifyImageCommand/5799.
):
  mini_magick (4.5.1) lib/mini_magick/shell.rb:18:in `run'
owen2345 commented 8 years ago

Fixed! The problem was a null value sent from js

mazharoddin commented 8 years ago

Thanks @owen2345, let me check if its working.

mazharoddin commented 8 years ago

Hi @owen2345, I am able to crop the images now, but dimensions are not getting updated if I use cloudfront/S3 images, so am unable to insert image( insert option is blank).

screen shot 2016-07-27 at 08 53 20
owen2345 commented 8 years ago

Fixed image insert

mazharoddin commented 8 years ago

Thanks @owen2345