VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Dragoner on March 30, 2021, 09:43:26 AM

Title: Ecological fee
Post by: Dragoner on March 30, 2021, 09:43:26 AM
Hi, I'm solving the problem with displaying the environmental fee for car bulbs.

I need show in cart under product environmental (ecological fee).
I have custom field name as ecological fee ... etc.
In product a select them, but I can't enter the amount, I have to enter it as a value, because it must not be added to the price of the product. The price in the basket is final for the product, including the fee. I only need to display information about the amount of the fee for the given product. Which I did in part. But if I add 2 pieces of product to the cart, the amount of the fee will not double.

Attachments
1. poplatek.png --- product in cart, 1 piece
2. poplatek 2pieces.png --- product in cart, 2 pieces, bad fee
3. product_cumstomfield_detail.png --- product detail (custom field)

Is possilble make custom field with price show under product in cart (like image 1), but with calculate this field x product pieces?

Thank you very much

PS: I´m building now 2 eshop, where i must use it :(

Version VM:  3.8.8 10472
Title: Re: Ecological fee
Post by: GJC Web Design on March 30, 2021, 10:30:22 AM
perhaps ->  https://forum.virtuemart.net/index.php?topic=127362.0
Title: Re: Ecological fee
Post by: pinochico on March 30, 2021, 13:15:21 PM
Roozhodně není možné použít klasický customfiled typu string.
Ten Vám nespočítá poplatek podle počtu ks.

Musíte použít jiný typ customfiledu, který bude měnit cenu poplatku (ne celkovou cenu produktu).

Buď ten co odkazuje GJC, ale musíte zajistit by byl viditelný jen v košíku a v emailu a na detailu produktu nebylo možné si ho uživatelsky měni
nebo zkuste najít jiný typ customfiledu na internetu.
začal bych známými firmami jako je Breakdesign, Daycount a další.

---

It is definitely not possible to use a classic customfiled type of string.
He will not calculate the fee for you according to the number of pieces.

You must use another type of customfiled that will change the price of the fee (not the total price of the product).

Either the one that links GJC, but you must ensure it would be visible only in the cart and in the email and it was not possible to change it by user on the product detail
or try to find another type of customfiled on the internet.
I would start with famous companies like Breakdesign, Daycount and others.
Title: Re: Ecological fee
Post by: Dragoner on March 30, 2021, 20:10:52 PM
Díky moc za odpověď, zkusím zaslaný plugin.
----
Thanks for reply, I try it.
Title: Re: Ecological fee
Post by: Dragoner on April 01, 2021, 14:01:38 PM
HI, GJC Web Design ... i try all of the variants, but the variant price does not rise (in attachment).

Thank you for your reply.

David
Title: Re: Ecological fee
Post by: Dragoner on April 02, 2021, 11:56:56 AM
Hi, i solved by this code by field weight on product.

<?php function cWeight($products){
      $tweight= 0;
      foreach ( $products as $prow) {
         $tweight += $prow->product_weight*$prow->quantity;
      }
return $tweight;
   } ?>


Then, you can echo it anywhere you want like this


   <?php echo cWeight($this->cart->products);?>

I add this code to cart.

Title: Re: Ecological fee
Post by: pinochico on April 02, 2021, 16:07:51 PM
hmmm, i think is not right

then in future you stop function shipping by weight, because you use this field for fee
Title: Re: Ecological fee
Post by: Dragoner on April 03, 2021, 10:55:42 AM
I know, but there is no another idea .. :(
Title: Re: Ecological fee
Post by: Dragoner on April 03, 2021, 11:10:46 AM
Ok, I rewrite script ... now I use field in attachment.

This field i never use :)

David