Ejemplo n.º 1
0
/**
 * DEVUELVE EL HTML DE LOS INGREDIENTES
 */
function getHtmlIngredientes($ingredientes, $producto_id)
{
    $html = '<h2 class="[ text-center color-dark ][ no-margin--top ]">' . get_the_title($producto_id) . '</h2>';
    $html .= '<div class="[ row ]">';
    if (!empty($ingredientes)) {
        foreach ($ingredientes as $key => $ingrediente) {
            $html .= '<div class="[ col-xs-3 col-md-2 ]">';
            $html .= '<a class="[ box-content ]" href="' . site_url('/recetas/') . '?ingrediente=' . $ingrediente->ingrediente_id . '">';
            $url_img = attachment_image_url($ingrediente->ingrediente_id, 'medium');
            $html .= '<img class="[ image-responsive ]" alt="" src="' . $url_img . '">';
            $html .= '<p class="[ text-center ]">' . get_the_title($ingrediente->ingrediente_id) . '</p>';
            $html .= '</a>';
            $html .= '</div>';
        }
    }
    $html .= '</div>';
    $producto = wc_get_product($producto_id);
    $variations = $producto->get_available_variations();
    $addToCart = '';
    $costoVariationSemanal = 0;
    $costoTotal = 0;
    $html .= '<div class="[ card__radio-options ][ text-center color-dark ]">';
    $html .= '<div class="[ radio-options__label ]">';
    $html .= 'Entregas semanales durante:';
    $html .= '</div>';
    if (!empty($variations)) {
        $count = 1;
        foreach ($variations as $variation) {
            $name = getNameVariation($variation['variation_id']);
            $check = $count == 1 ? 'checked' : '';
            $nombreVariacion = getNameOriginVariation($variation['variation_id']);
            $cansatSemanal = getCostoCanastaTemporalidad($nombreVariacion, $variation['display_price']);
            if ($count == 1) {
                $addToCart = site_url('/mi-carrito/?add-to-cart=') . $variation['variation_id'];
                $costoVariationSemanal = $cansatSemanal;
                $costoTotal = $variation['display_price'];
            }
            $html .= '<label class="[ radio-options__selector__label ]" for="c9_meals-' . $variation['variation_id'] . '">';
            $html .= '<input ';
            $html .= 'id="c9_meals-' . $variation['variation_id'] . '"';
            $html .= 'data-costo="' . number_format($variation['display_price']) . '"';
            $html .= 'data-producto="' . $producto_id . '"';
            $html .= 'data-variacion="' . $variation['variation_id'] . '"';
            $html .= 'data-semanal="' . $cansatSemanal . '"';
            $html .= 'class="[ radio-options__selector ][ check-compra-modal ]" ';
            $html .= 'type="radio"';
            $html .= 'name="variaciones-00' . $producto_id . '"';
            $html .= 'value="c9"';
            $html .= $check;
            $html .= '>' . $name;
            $html .= '</label>';
            $count++;
        }
    }
    $html .= '</div>';
    $html .= '<div class="text-center">';
    $html .= '<a class="[ btn btn-secondary ] url-add-cart-product-modal-00' . $producto_id . '" href="' . $addToCart . '">Añadir al carrito</a>';
    $html .= '</div>';
    return $html;
}
Ejemplo n.º 2
0
/**
 * REGRESA EL COSTO DEL PRODUCTO
 * @param  [int] $variant_id [variant id]
 * @return [type]             [description]
 */
function getCostoVariationID($variant_id)
{
    $temporalidad = get_post_meta($variant_id, 'attribute_pa_temporalidad', true);
    $regular_price = get_post_meta($variant_id, '_regular_price', true);
    $costo = getCostoCanastaTemporalidad($temporalidad, $regular_price);
    return (object) ['temporalidad' => $temporalidad, 'costo' => $regular_price, 'costoSemanal' => $costo];
}
Ejemplo n.º 3
0
">
                                </div>
                                <div class="[ card__footer ]">

                                    <div class="[ card__radio-options ][ text-center ]">
                                        <div class="[ radio-options__label ]">
                                                Entregas semanales durante:
                                        </div>
                                        <?php 
        if (!empty($variations)) {
            $count = 1;
            foreach ($variations as $variation) {
                $name = getNameVariation($variation['variation_id']);
                $check = $count == 1 ? 'checked' : '';
                $nombreVariacion = getNameOriginVariation($variation['variation_id']);
                $cansatSemanal = getCostoCanastaTemporalidad($nombreVariacion, $variation['display_price']);
                if ($count == 1) {
                    $addToCart = site_url('/mi-carrito/?add-to-cart=') . $variation['variation_id'];
                    $costoVariationSemanal = $cansatSemanal;
                    $costoTotal = $variation['display_price'];
                }
                ?>
                                                <label class="[ radio-options__selector__label ]" for="c9_meals-<?php 
                echo $variation['variation_id'];
                ?>
">
                                                    <input
                                                        id="c9_meals-<?php 
                echo $variation['variation_id'];
                ?>
"