[SOLVED] Modifying woo-price-calculator.php – Cart and Checkout Variation output

Home – SaaS Forums Support questions WooPrice Calculator (Pro) [SOLVED] Modifying woo-price-calculator.php – Cart and Checkout Variation output

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8152
    Josh Terrell
    Participant

    Hello,

    I want to clean up the way the variations are displayed in the Cart and the Checkout forms. I am trying to modify the following function:

    /*
    * Eseguito in review-order.php per rivedere l'ordine
    */
    /*WPC-PRO*/
    function woocommerce_checkout_cart_item_quantity($productTitle, $cartItem){
    if(isset($cartItem['simulator_id'])){
    $simulatorId = $cartItem['simulator_id'];

    if(!empty($simulatorId)){
    $simulatorFieldsIds = $this->calculatorHelper->get_simulator_fields($simulatorId);
    $simulatorFields = $this->fieldHelper->get_fields_by_ids($simulatorFieldsIds);
    $simulatorFieldsData = $cartItem['simulator_fields_data'];

    foreach($simulatorFields as $simulatorKey => $simulatorField){
    $fieldId = $this->plugin_short_code . '_' . $simulatorField->id;

    $label = $this->wsf->userTrans($simulatorField->label);
    $value = $simulatorFieldsData[$fieldId];

    $htmlElement = $this->getReviewElement($simulatorField, $value);
    $title[] = "  {$label}: {$htmlElement}";
    }

    return "{$productTitle}
    " . implode("
    ", $title) . "

    ";
    }else{
    return $productTitle; // Nessuna modifica se non è un simulatore
    }
    }
    }

    Instead of breaks I want to use the following description list elements similar to the default Woocommerce variation list(but with UIKIT styling):

    $title[] = "

    {$label}
    {$htmlElement}

    ";
    }

    return "{$productTitle}

    " . implode("", $title) . "

    ";

    The problem is, whenever I attempt to use any HTML syntax with a class, I get an internal 500 error and the entire website will not load. I have the same problem when I try to replace the Check and X images with font awesome icons in the following lines:

    public function getReviewElement($field, $value){
    if($field->type == "checkbox"){
    $tickImageUrl = $this->wsf->getImageUrl("tick.png");
    $crossImageUrl = $this->wsf->getImageUrl("cross.png");

    if($value === "on"){
    return "";
    }else{
    return "";
    }

    #8153
    Josh Terrell
    Participant

    I figured out my problem. I wasn’t escaping the quotes. The following works:

    $title[] = "

    {$label}
    {$htmlElement}

    ";
    }

    return "{$productTitle}

    " . implode("", $title) . "

    ";

    and

    if($value === "on"){
    return "";
    }else{
    return "";
    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.