在Woocommerce结帐中将“本地代答”文本更改为其他内容

时间:2018-11-28 20:04:01

标签: php wordpress woocommerce label shipping-method

我的结帐当前看起来像这样,在woocommerce后端中启用了“本地取件”:

enter image description here

是否可以将其更改为“从我们的商店提货”?

“运输”部分的源代码为:

<tr class="shipping">
    <th>Shipping</th>
    <td data-title="Shipping">
                    <ul id="shipping_method">
                                    <li>
                        <input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flat_rate1" value="flat_rate:1" class="shipping_method"  />
                                <label for="shipping_method_0_flat_rate1">Standard: <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">&#x62f;.&#x625;</span>30.00</span></label>                 </li>
                                    <li>
                        <input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_local_pickup2" value="local_pickup:2" class="shipping_method"  checked='checked' />
                                <label for="shipping_method_0_local_pickup2">Local pickup: <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">&#x62f;.&#x625;</span>0.00</span></label>                   </li>
                            </ul>


            </td>
</tr>

谢谢!

3 个答案:

答案 0 :(得分:1)

您可以直接从中更改

Woocommerce =>设置=>发货区域=>编辑(您需要更改的区域名称)=>发货方式=>编辑(本地取件)=>根据需要更改标签,一切就绪。 >

答案 1 :(得分:0)

将此添加到您的主题(如果正在使用,则添加到子主题)function.php文件:

add_filter( 'woocommerce_cart_shipping_method_full_label', 'remove_local_pickup_free_label', 10, 2 );
function remove_local_pickup_free_label($full_label, $method){
    if( $method->id == 'shipping_method_0_local_pickup2' )
    $full_label = str_replace("Local Pickup","Store Pickup",$full_label);
  return $full_label;
}

答案 2 :(得分:0)

正确的工作代码应为:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

typedef struct card_s{
char suit[7];
int value;
struct card_s *next, *previous;
}card;

int rand_gen(int count){
    double frac;
    frac = (double)rand()/((double)RAND_MAX+1);
    return floor(count * frac); //random number in [0, count]
}



void addCard(card *p, card **hl, card **hr, FILE *inp){

card *temp; // pointer to a node_t
temp = (card *)malloc(sizeof (card)); // new node creation

       fscanf(inp, "%d", &temp->value);
fscanf(inp, "%s", temp->suit);


                    if (*hl == NULL){ // if left head is null, i.e., list is empty
                        temp->previous = NULL;
                        temp->next = NULL;
                        *hl = temp;
                        *hr = temp;
                    }
                    else if (p->next == NULL){ // if adding at the end of list
                          temp->previous = p;
                        temp->next = NULL;
                        p->next = temp;
                        *hr = temp;
                    }
                    else{     // if adding to the middle of the list
                        temp->next = p-> next;
                        temp->previous = p;
                        p->next = temp;
                        temp->next->previous = temp;
                    }
                    }

void Print(card **headl)  { //this function prints from left to right only
    card *temp;
    temp = (*headl);
    while(temp != NULL) {
        printf("|");
        printf("%d", temp->value);
        if(strcmp(temp->suit,"hea")==0) {
            printf("♥");
        }
        if(strcmp(temp->suit,"clu")==0) {
            printf("♣");
        }
        if(strcmp(temp->suit,"spa")==0) {
            printf("♠");
        }
        if(strcmp(temp->suit,"dia")==0) {
            printf("♦");
        }
        printf("|");
        //printf("%s ", temp->suit);
        temp = temp->next;
    }
}
void Print1(card **headl)  { //this function prints from left to right only
card *temp;
temp = (*headl);
while(temp != NULL) {
    for(int i = 0; i < 13; i++) {
    printf("|");
        if(temp->value == 11){
           printf("J");
        }
        else if(temp->value == 12) {
            printf("Q");
        }
        else if(temp->value == 13) {
            printf("K");
        }
        else if(temp->value == 14) {
            printf("A");
        }
        else {
            printf("%d", temp->value);
        }

    if(strcmp(temp->suit,"h")==0) {
        printf("♥");
    }
    if(strcmp(temp->suit,"c")==0) {
        printf("♣");
    }
    if(strcmp(temp->suit,"s")==0) {
        printf("♠");
    }
    if(strcmp(temp->suit,"d")==0) {
        printf("♦");
    }
    printf("|");

    //printf("%s ", temp->suit);
    temp = temp->next;
    }
    printf("\n");
}
}

void swap(card *pt, int i, int j) {

card *temp;
temp = (card *)malloc(sizeof(card));
card *temp1 = pt, *temp2 = pt;  //creates temperaries that start from the head left

for(int x = 0; x < i; x++) { //counts the number of nodes until i
    temp1 = temp1->next;
}

for(int x = 0; x < j; x++) { //counts the number of nodes until j
    temp2 = temp2->next;
}
temp->value = temp1->value;  //swaps the information not the nodes
strcpy(temp->suit,temp1->suit);
temp1->value = temp2->value;
strcpy(temp1->suit, temp2->suit);
temp2->value = temp->value;
strcpy(temp2->suit, temp->suit);

}




int main(void)  {
FILE *inp = NULL;
inp = fopen("cards.txt", "r");
srand((int)time(NULL));
card *headl = NULL, *headr = NULL;

for(int i = 0; i < 52; i++) {
    addCard(headr, &headl, &headr, inp);
}

if(inp == NULL) {
    printf("No file found");
    return -1;
}

printIntro();

printf("\n");

Print1(&headl);

printf("\n");
printf("\n");


for(int i = 0; i <= 45; i++) {  //does the swap function swap number times
        swap(headl, rand_gen(52), rand_gen(52));
       }

Print1(&headl);


return(0);
}

代码进入您的活动子主题(或活动主题)的function.php文件中。经过测试,可以正常工作。

相似的答案:Add different custom labels to Woocommerce shipping methods