Я хочу добавить class = "notranslate" только к атрибуту продукта под названием "MARCAJE", ярлык "pa_marcaje". Что я делаю не так ??
Не могли бы вы мне помочь ??
Это код:
foreach ($available_variations as $variation) {
$variation_product = new WC_Product_Variation( $variation['variation_id'] );
$this->td .= '<tr id="variations-table-row-' . $variation_product->get_id() . '" class="variations-table-row">';
foreach($this->variationsTableData as $variationsTableDataKey => $variationsTableDataValue) {
if($variationsTableDataKey == "at") {
foreach ($variation_product->get_attributes() as $attr_name => $attr_value) {
// Get the correct variation values
if (strpos($attr_name, 'pa_') !== FALSE){ // variation is a pre-definted attribute
// $attr_name = substr($attr_name, 3);
$attr = get_term_by('slug', $attr_value, $attr_name);
$attr_value = $attr->name;
$attr_name = wc_attribute_label($attr_name);
} else {
$attr = maybe_unserialize( get_post_meta( $product->get_id(), '_product_attributes' ) );
$attr_name = $attr[0][$attr_name]['name'];
}
if($this->first) {
$this->th .= '<th id="variations-table-header-' . $variationsTableDataKey . '" class="variations-table-header">' . $attr_name . '</th>';
$this->columnCount++;
}
// Это код, который я пишу
if($attr_name['name'] == "pa_marcaje"{
$this->td .= '<td data-th="' . $attr_name . '" class="variations-table-value-' . $variationsTableDataKey . ' variations-table-value . notranslate">' . $attr_value . '</td>';
}else{
// пока здесь
$this->td .= '<td data-th="' . $attr_name . '" class="variations-table-value-' . $variationsTableDataKey . ' variations-table-value">' . $attr_value . '</td>';
}
}
continue;
}