Adding a Virtuemart 2 'custom field' to the gift voucher


  • Default avatar
    allan0    
     3 years ago
    0

    Hi,

    I have done this before with Virtuemart 1.

    However, can you help confirm how I can add the selected option to the voucher.

    When the customer buys a flying lesson from us we want them to select their choice of airport to fly from. (Custom field). They may require to pay extra depending on their choice which Virtuemart handles.

    I need the choice to be printed on the gift certificate.

    Thanks,

    Allan
  • Your avatar
    seyi    
     3 years ago
    0

    Hello,

    By choice, you mean the product purchased? Yes, this can be done by using the tag {product_name} in the gift certificate profile created.
  • Default avatar
    allan0    
     3 years ago
    0

    Seyi,

    I want the 'optional' selection to be added to the voucher.

    E.g. Customer purchases a flying lesson. I want them to select from a choice of airport (virtuemart option). It is the airport I want yo appear so that we know it is valid at a particular airport.
  • Default avatar
    allan0    
     3 years ago
    0

    Seyi,

    It is not the product I want to add ; we already do this.

    It is the option selected on the product. If we have the same flight available at a choice of airport we want the airport selected at time of sale to be shown on the voucher.

    Allan
  • Your avatar
    seyi    
     3 years ago
    0

    Hello,

    So you want to display the product attribute? There is no tag for it. You can try this,
    in www/administrator/components/con_awocoupon/helpers/estoregiftcerthandler.php, around line 100 is this:
    <?php
                        $allcodes
    [$this_mail_key['email']][] = array(
                                            
    'id'=>$coupon_row->id,
                                            
    'order_item_id'=>$row->order_item_id,
                                            
    'user_id'=>$row->user_id,
                                            
    'product_id'=>$row->product_id,
                                            
    'product_name'=>$row->order_item_name,
                                            
    'email'=>$row->email,
                                            
    'code'=>$coupon_row->coupon_code,
                                            
    'price'=>$price,
                                            
    'expiration'=>$coupon_row->expiration,
                                            
    'expirationraw'=>!empty($coupon_row->expiration) ? strtotime($coupon_row->expiration) : 0,
                                            
    'profile'=>$current_profile,
                                            
    'file'=>'',
                                    );
    ?>


    change it to this
    <?php
                        
    if(!class_exists('VirtueMartModelCustomfields'))require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'customfields.php');
                        
    $x = (object)array('product_attribute'=>$row->product_attribute);
                        
    $product_attribute VirtueMartModelCustomfields::CustomsFieldOrderDisplay($x,'BE');

                        
    $allcodes[$this_mail_key['email']][] = array(
                                            
    'id'=>$coupon_row->id,
                                            
    'order_item_id'=>$row->order_item_id,
                                            
    'user_id'=>$row->user_id,
                                            
    'product_id'=>$row->product_id,
                                            
    'product_name'=>$row->order_item_name,
                                            
    'email'=>$row->email,
                                            
    'code'=>$coupon_row->coupon_code,
                                            
    'price'=>$price,
                                            
    'expiration'=>$coupon_row->expiration,
                                            
    'expirationraw'=>!empty($coupon_row->expiration) ? strtotime($coupon_row->expiration) : 0,
                                            
    'profile'=>$current_profile,
                                            
    'file'=>'',
                                            
    'product_attribute'=>$product_attribute,
                                    );
    ?>




    around lines 190 is this

            '{product_name}',

    Right after that add
            '{product_attribute}',


    Then around lines 211 and is this
                                                $row['product_name'],

    right after that add this
                                                $row['product_attribute'],


    Now use the tag {product_attribute}
  • Default avatar
    allan0    
     3 years ago
    0

    Parse error: syntax error, unexpected T_REQUIRE in /var/www/vhosts/flyleadingedge.co.uk/httpdocs/administrator/components/com_awocoupon/helpers/estore/estoregiftcerthandler.php on line 100

    Hi,
    Any idea what is wrong? I followed your instructions....

    Allan

    www.flyleadingedge.co.uk
  • Your avatar
    seyi    
     3 years ago
    0

    No not really. Did you add the <\?php and ?\> tags? You should not, those are just there to beautify the code.
  • Default avatar
    allan0    
     3 years ago
    0

    Parse error: syntax error, unexpected T_REQUIRE in /var/www/vhosts/flyleadingedge.co.uk/httpdocs/administrator/components/com_awocoupon/helpers/estore/estoregiftcerthandler.php on line 100

    Hi,

    I cannot see any error I have made in copying it. I have pasted below a section:-

    $price = '';
    if(!empty($coupon_row->coupon_value))
    $price = $coupon_row->coupon_value_type=='amount'
    ? $this->formatcurrency($coupon_row->coupon_value)
    : round($coupon_row->coupon_value).'%';

      if(!class_exists('VirtueMartModelCustomfields'))require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'customfields.php');
                        $x = (object)array('product_attribute'=>$row->product_attribute);
                        $product_attribute = VirtueMartModelCustomfields::CustomsFieldOrderDisplay($x,'BE');


    $allcodes[$this_mail_key['email']][] = array(
    'id'=>$coupon_row->id,
    'order_item_id'=>$row->order_item_id,
    'user_id'=>$row->user_id,
    'product_id'=>$row->product_id,
    'product_name'=>$row->order_item_name,
    'email'=>$row->email,
    'code'=>$coupon_row->coupon_code,
    'price'=>$price,
    'expiration'=>$coupon_row->expiration,
    'expirationraw'=>!empty($coupon_row->expiration) ? strtotime($coupon_row->expiration) : 0,
    'profile'=>$current_profile,
    'file'=>'',
    'product_attribute'=>$product_attribute,
    );
    if(!empty($row->vendor_email)) {
    $vendor_codes[$row->vendor_email]['name'] = $row->vendor_name;
  • Your avatar
    seyi    
     3 years ago
    0

    I am not seeing any problems, which line is line 100?
  • Default avatar
    allan0    
     3 years ago
    0

      if(!class_exists('VirtueMartModelCustomfields'))require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'customfields.php');